<!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7" lang="en-US" prefix="og: http://ogp.me/ns#">
<![endif]-->
<!--[if IE 8]>
<html class="ie ie8" lang="en-US" prefix="og: http://ogp.me/ns#">
<![endif]-->
<!--[if !(IE 7) & !(IE 8)]><!-->
<html lang="en-US" prefix="og: http://ogp.me/ns#">
<!--<![endif]-->
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="" />
<!--[if lt IE 9]>
<script src="http://devzone.zend.com/wp-content/themes/zerogravity/js/html5.js" type="text/javascript"></script>
<![endif]-->


<!-- This site is optimized with the Yoast SEO plugin v2.3.4 - https://yoast.com/wordpress/plugins/seo/ -->
<title>Wrapping C++ Classes in a PHP Extension - Zend Developer Zone</title>
<link rel="canonical" href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/" />
<meta property="og:locale" content="en_US" />
<meta property="og:type" content="article" />
<meta property="og:title" content="Wrapping C++ Classes in a PHP Extension - Zend Developer Zone" />
<meta property="og:description" content="One of the most common reasons people write extensions for PHP is to link against an external library and make available its API to PHP userspace scripts. Often the external library is written in C or C++. If you are tasked with writing such an extension that links against an object oriented C++ library, you will probably want to wrap the C++ classes and make them available to PHP userspace scripts. This is pretty easy to do once you get over a few initial hurdles." />
<meta property="og:url" content="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/" />
<meta property="og:site_name" content="Zend Developer Zone" />
<meta property="article:section" content="Tutorials" />
<meta property="article:published_time" content="2009-04-22T10:17:15+00:00" />
<!-- / Yoast SEO plugin. -->

<link rel="alternate" type="application/rss+xml" title="Zend Developer Zone &raquo; Feed" href="http://devzone.zend.com/feed/" />
<link rel="alternate" type="application/rss+xml" title="Zend Developer Zone &raquo; Comments Feed" href="http://devzone.zend.com/comments/feed/" />
<link rel="alternate" type="application/rss+xml" title="Zend Developer Zone &raquo; Wrapping C++ Classes in a PHP Extension Comments Feed" href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/feed/" />
		<script type="text/javascript">
			window._wpemojiSettings = {"baseUrl":"http:\/\/s.w.org\/images\/core\/emoji\/72x72\/","ext":".png","source":{"concatemoji":"http:\/\/devzone.zend.com\/wp-includes\/js\/wp-emoji-release.min.js"}};
			!function(a,b,c){function d(a){var c=b.createElement("canvas"),d=c.getContext&&c.getContext("2d");return d&&d.fillText?(d.textBaseline="top",d.font="600 32px Arial","flag"===a?(d.fillText(String.fromCharCode(55356,56812,55356,56807),0,0),c.toDataURL().length>3e3):(d.fillText(String.fromCharCode(55357,56835),0,0),0!==d.getImageData(16,16,1,1).data[0])):!1}function e(a){var c=b.createElement("script");c.src=a,c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var f,g;c.supports={simple:d("simple"),flag:d("flag")},c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.simple&&c.supports.flag||(g=function(){c.readyCallback()},b.addEventListener?(b.addEventListener("DOMContentLoaded",g,!1),a.addEventListener("load",g,!1)):(a.attachEvent("onload",g),b.attachEvent("onreadystatechange",function(){"complete"===b.readyState&&c.readyCallback()})),f=c.source||{},f.concatemoji?e(f.concatemoji):f.wpemoji&&f.twemoji&&(e(f.twemoji),e(f.wpemoji)))}(window,document,window._wpemojiSettings);
		</script>
		<style type="text/css">
img.wp-smiley,
img.emoji {
	display: inline !important;
	border: none !important;
	box-shadow: none !important;
	height: 1em !important;
	width: 1em !important;
	margin: 0 .07em !important;
	vertical-align: -0.1em !important;
	background: none !important;
	padding: 0 !important;
}
</style>
<link rel='stylesheet' id='crayon-css'  href='http://devzone.zend.com/wp-content/plugins/crayon-syntax-highlighter/css/min/crayon.min.css' type='text/css' media='all' />
<link rel='stylesheet' id='crayon-theme-bncplusplus-css'  href='http://devzone.zend.com/wp-content/plugins/crayon-syntax-highlighter/themes/bncplusplus/bncplusplus.css' type='text/css' media='all' />
<link rel='stylesheet' id='crayon-font-monaco-css'  href='http://devzone.zend.com/wp-content/plugins/crayon-syntax-highlighter/fonts/monaco.css' type='text/css' media='all' />
<link rel='stylesheet' id='digg-digg-css'  href='http://devzone.zend.com/wp-content/plugins/digg-digg/css/diggdigg-style.css' type='text/css' media='screen' />
<link rel='stylesheet' id='social_comments-css'  href='http://devzone.zend.com/wp-content/plugins/social/assets/comments.css' type='text/css' media='screen' />
<link rel='stylesheet' id='zerogravity-fonts-css'  href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700&#038;subset=latin,latin-ext' type='text/css' media='all' />
<link rel='stylesheet' id='zerogravity-style-css'  href='http://devzone.zend.com/wp-content/themes/devzone-zerogravity/style.css' type='text/css' media='all' />
<link rel='stylesheet' id='custom-style-css'  href='http://devzone.zend.com/wp-content/themes/zerogravity/custom-style.css' type='text/css' media='all' />
<!--[if lt IE 9]>
<link rel='stylesheet' id='zerogravity-ie-css'  href='http://devzone.zend.com/wp-content/themes/zerogravity/css/ie.css' type='text/css' media='all' />
<![endif]-->
<link rel='stylesheet' id='dashicons-css'  href='http://devzone.zend.com/wp-includes/css/dashicons.min.css' type='text/css' media='all' />
<link rel='stylesheet' id='font-awesome-css'  href='http://devzone.zend.com/wp-content/themes/zerogravity/css/font-awesome-4.3.0/css/font-awesome.min.css' type='text/css' media='all' />
<!-- This site uses the Google Analytics by Yoast plugin v5.4.6 - Universal enabled - https://yoast.com/wordpress/plugins/google-analytics/ -->
<script type="text/javascript">
	(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
		(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
		m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
	})(window,document,'script','//www.google-analytics.com/analytics.js','__gaTracker');

	__gaTracker('create', 'UA-291885-3', 'auto');
	__gaTracker('set', 'forceSSL', true);
	__gaTracker('require', 'displayfeatures');
	__gaTracker('require', 'linkid', 'linkid.js');
	__gaTracker('send','pageview');

</script>
<!-- / Google Analytics by Yoast -->
<script type='text/javascript' src='http://devzone.zend.com/wp-includes/js/jquery/jquery.js'></script>
<script type='text/javascript' src='http://devzone.zend.com/wp-includes/js/jquery/jquery-migrate.min.js'></script>
<script type='text/javascript'>
/* <![CDATA[ */
var CrayonSyntaxSettings = {"version":"2.7.1","is_admin":"0","ajaxurl":"http:\/\/devzone.zend.com\/wp-admin\/admin-ajax.php","prefix":"crayon-","setting":"crayon-setting","selected":"crayon-setting-selected","changed":"crayon-setting-changed","special":"crayon-setting-special","orig_value":"data-orig-value","debug":""};
var CrayonSyntaxStrings = {"copy":"Press %s to Copy, %s to Paste","minimize":"Click To Expand Code"};
/* ]]> */
</script>
<script type='text/javascript' src='http://devzone.zend.com/wp-content/plugins/crayon-syntax-highlighter/js/min/crayon.min.js'></script>
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://devzone.zend.com/xmlrpc.php?rsd" />
<link rel='shortlink' href='http://devzone.zend.com/?p=1435' />

<!-- This site is using AdRotate v3.15 Professional to display their advertisements - https://ajdg.solutions/products/adrotate-for-wordpress/ -->
<!-- AdRotate CSS -->
<style type="text/css" media="screen">
	.g { margin:0px; padding:0px; overflow:hidden; line-height:1; zoom:1; }
	.g img { height:auto; }
	.g-col { position:relative; float:left; }
	.g-col:first-child { margin-left: 0; }
	.g-col:last-child { margin-right: 0; }
	@media only screen and (max-width: 480px) {
		.g-col, .g-dyn, .g-single { width:100%; margin-left:0; margin-right:0; }
	}
</style>
<!-- /AdRotate CSS -->

	<style type='text/css'>
		a {color: #0098D3;}
	a:hover {color: #0098D3;}
	.blog-info-sin-imagen {background-color: #0098D3;}
	.social-icon-wrapper a:hover {color: #0098D3;}
	.toggle-search {color: #0098D3;}
	.prefix-widget-title {color: #0098D3;}
	.term-icon {color: #0098D3;}
	
	.sub-title a:hover {color:#0098D3;}
	.entry-content a:visited,.comment-content a:visited {color:#0098D3;}
	input[type="submit"] {background-color:#0098D3 !important;}
	.bypostauthor cite span {background-color:#0098D3;}
	.site-header h1 a:hover,
	.site-header h2 a:hover {
		color: #0098D3;
	}
	.entry-header .entry-title a:hover {color:#0098D3 ;}
	.archive-header {border-left-color:#0098D3;}
	.main-navigation a:hover,
	.main-navigation a:focus {
		color: #0098D3;
	}
	.widget-area .widget a:hover {
		color: #0098D3 !important;
	}
	footer[role="contentinfo"] a:hover {
		color: #0098D3;
	}
	.entry-meta a:hover {
	color: #0098D3;
	}
	.format-status .entry-header header a:hover {
		color: #0098D3;
	}
	.comments-area article header a:hover {
		color: #0098D3;
	}
	a.comment-reply-link:hover,
	a.comment-edit-link:hover {
		color: #0098D3;
	}
	.template-front-page .widget-area .widget li a:hover {
		color: #0098D3;
	}
	.main-navigation .current-menu-item a,
	.main-navigation .current-menu-ancestor > a,
	.main-navigation .current_page_item > a,
	.main-navigation .current_page_ancestor > a {color: #0098D3;}
	.currenttext, .paginacion a:hover {background-color:#0098D3;}
	.main-navigation li a:hover  {color: #0098D3;}
	.aside{border-left-color:#0098D3 !important;}
	blockquote{border-left-color:#0098D3;}
	.logo-header-wrapper, .image-header-wrapper {background-color:#0098D3;}
	h2.comments-title {border-left-color:#0098D3;}
	
		
		
		
			
		body.custom-font-enabled {font-family: "Open Sans", Arial, Verdana;}
	
			@media screen and (min-width: 600px) {
			#primary {float:left;}
			#secondary {float:right;}
			.site-content {
				border-left: none;
				padding-left:0;
				padding-right: 24px;
				padding-right:1.714285714285714rem;
				/*border-right: 1px solid #e0e0e0;*/
			}
		}
		@media screen and (min-width: 960px) {
			.site-content {
				border-right: 1px solid #e0e0e0;
			}
		}
		
	@media screen and (max-width: 599px) {
		.menu-toggle, .menu-toggle:hover {
			background:#0098D3 !important;
			color:#ffffff !important;
			width:100%;
		}
	}
	</style>
	
<style type="text/css">.c2c-blog-time-widget-time { display:none; }#wpadminbar .c2c-blog-time-widget-display a { padding:0; }</style>
<script type="text/javascript">var ajaxurl = 'http://devzone.zend.com/wp-admin/admin-ajax.php';</script>
			
							<style id="tt-easy-google-font-styles" type="text/css">
			
																						p {
													}
								
																										h1 {
													}
								
																										h2 {
													}
								
																										h3 {
													}
								
																										h4 {
													}
								
																										h5 {
													}
								
																										h6 {
													}
								
										
							</style>
						</head>

<body class="single single-post postid-1435 single-format-standard custom-font-enabled">

<a name='inicio_pagina'></a>

<div id="page" class="hfeed site">
	<div class="top-bar">
				
		<div class="boton-menu-movil"><i class="fa fa-align-justify"></i></div>
				<div class="blog-title-wrapper">Zend Developer Zone</div>
				<div class="toggle-search"><i class="fa fa-search"></i></div>
		<div class="social-icon-wrapper">
							<a href="https://twitter.com/devzone" title="Twitter" target="_blank"><i class="fa fa-twitter"></i></a> 
						
						
						
						
						
						
						
					</div><!-- .social-icon-wrapper -->	
	</div><!-- .top-bar --->
	
	<div class="wrapper-search-top-bar"><div class="search-top-bar">	<div>
		<form method="get" id="searchform-toggle" action="http://devzone.zend.com/">
			<label for="s" class="assistive-text">Search</label>
			<input type="search" class="txt-search" name="s" id="s" />
			<input type="submit" name="submit" id="btn-search" value="Search" />
		</form>
    </div></div></div>
	
	<header id="masthead" class="site-header" role="banner">
	<div style="position:relative">
<div id="menu-movil">
	<div class="search-form-movil">
		<form method="get" id="searchform-movil" action="http://devzone.zend.com/">
			<label for="s" class="assistive-text">Search</label>
			<input type="search" class="txt-search-movil" placeholder="Search..." name="s" id="s" />
			<input type="submit" name="submit" id="btn-search-movil" value="Search" />
		</form>
    </div><!-- search-form-movil -->
	<div class="menu-movil-enlaces">
			</div>
	
	<div class="social-icon-wrapper">
							<a href="https://twitter.com/devzone" title="Twitter" target="_blank"><i class="fa fa-twitter"></i></a> 
						
						
						
						
						
						
						
					</div><!-- .social-icon-wrapper -->	
</div><!-- #menu-movil --></div>
						
				<div class="image-header-wrapper">				<a href="http://devzone.zend.com/"><img src="http://devzone.zend.com/wp-content/uploads/2015/07/cropped-2265072565_4c850da205_o.jpg" class="header-image" width="1280" height="293" alt="Zend Developer Zone" /></a>
				</div><!-- .logo-header-wrapper or .image-header-wrapper -->
				
				
		<nav id="site-navigation" class="main-navigation" role="navigation">
			<a class="assistive-text" href="#content" title="Skip to content">Skip to content</a>
					</nav><!-- #site-navigation -->

		
	</header><!-- #masthead -->

	<div id="main" class="wrapper">
	<div id="primary" class="site-content">
		<div id="content" role="main">

			
				
	<article id="post-1435" class="post-1435 post type-post status-publish format-standard hentry category-tutorials">
		
		<header class="entry-header">
						<h1 class="entry-title">Wrapping C++ Classes in a PHP Extension</h1>
						
			<!-- Author, date and comments -->
            <div class='sub-title'>
				<div class="autor-fecha">
                	<i class="fa fa-user"></i> <a href='http://devzone.zend.com/author/community/'>Zend Community</a>&nbsp;&nbsp;
                 	<i class="fa fa-calendar-o"></i> April 22, 2009&nbsp;&nbsp;<i class="fa fa-comment-o"></i> <a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comments">33 Comments<span class="screen-reader-text"> on Wrapping C++ Classes in a PHP Extension</span></a>               </div>
                <!--<div class="popup-comments"> </div>-->
            </div><!-- .sub-title -->
		</header><!-- .entry-header -->
		
		<!-- Subtitle widget area -->
					<div class="sub-title-widget-area">
							</div><!-- .sub-title-widget-area -->	
				
				
			<div class="entry-content">
				<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/" data-count="horizontal" data-text="Wrapping C++ Classes in a PHP Extension" data-via="devzone" ></a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script></div><div class='dd_button'><script src="//connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><script type='text/javascript' src='https://apis.google.com/js/plusone.js'></script><g:plusone size='medium' href='http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/'></g:plusone></div><div class='dd_button'><script src='//platform.linkedin.com/in.js' type='text/javascript'></script><script type='IN/Share' data-url='http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/' data-counter='right'></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>One of the most common reasons people write extensions for PHP is to link against an external library and make available its API to PHP userspace scripts. Often the external library is written in C or C++. If you are tasked with writing such an extension that links against an object oriented C++ library, you will probably want to wrap the C++ classes and make them available to PHP userspace scripts. This is pretty easy to do once you get over a few initial hurdles.</p>
<p>In this tutorial I am going to walk you through creating a PHP extension called &#8220;vehicles&#8221; which will expose a single class called &#8220;Car&#8221; (obviously in the real-world, your extensions will expose many classes, but I’m trying to keep things simple). The extension will be built for PHP 5. I am only going to give instructions for building the extension in a UNIX-like environment, although most of what I cover should apply to Windows extension development as well. Most of what I detail here will be an expanded or simplified version of material covered in the somewhat abandoned Using C++ With PHP. I am not going to cover the basics of PHP extension writing, for that I recommend Sara Goleman’s <a href="http://devzone.zend.com/article/1021-Extension-Writing-Part-I-Introduction-to-PHP-and-Zend">Extension Writing</a> series or her book <a href="http://blog.libssh2.org/index.php?/archives/24-Extending-and-Embedding-PHP.html">Extending and Embedding PHP</a>.</p>
<h2>File Layout</h2>
<p>The extension you will be creating consists of several files which you should place in a directory called vehicles:</p>
<ul>
<li>car.h &#8211; Contains the definition of the C++ Car class.</li>
<li>car.cc &#8211; Contains the implementation of the C++ Car class.</li>
<li>php_vehicles.h &#8211; Contains PHP specific includes, external variables, etc.</li>
<li>vehicles.cc &#8211; The main source file of the extension. This will contain the PHP Car class.</li>
<li>config.m4 &#8211; PHP Build system / autoconf configuration file.</li>
</ul>
<h2>Configuring the PHP Build System</h2>
<p>In order to use C++ in your PHP extension, you must instruct the PHP build system to use a C++ compiler. This is done by calling the PHP_REQUIRE_CXX() macro in your config.m4 file. PHP_REQUIRE_CXX() is defined in aclocal.m4 in the root directory of the PHP source distribution and wraps the autoconf macro AC_PROG_CXX(), which is documented <a href="http://www.gnu.org/software/hello/manual/autoconf/C_002b_002b-Compiler.html">here</a>. You must also link the C++ standard library (libstdc++ on most systems), which is done with the PHP_ADD_LIBRARY() macro. Put the following in your config.m4 file:</p>
<p></p><!-- Crayon Syntax Highlighter v2.7.1 -->

		<div id="crayon-55ebd96717b7d833008530" class="crayon-syntax crayon-theme-bncplusplus crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
		
			<div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><span class="crayon-title"></span>
			<div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><div class="crayon-button crayon-nums-button" title="Toggle Line Numbers"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-plain-button" title="Toggle Plain Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-wrap-button" title="Toggle Line Wrap"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-expand-button" title="Expand Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-copy-button" title="Copy"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-popup-button" title="Open Code In New Window"><div class="crayon-button-icon"></div></div></div></div>
			<div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;"></div>
			<div class="crayon-plain-wrap"><textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">
PHP_ARG_ENABLE(vehicles,
    [Whether to enable the "vehicles" extension],
    [  --enable-vehicles      Enable "vehicles" extension support])

if test $PHP_VEHICLES != "no"; then
    PHP_REQUIRE_CXX()
    PHP_SUBST(VEHICLES_SHARED_LIBADD)
    PHP_ADD_LIBRARY(stdc++, 1, VEHICLES_SHARED_LIBADD)
    PHP_NEW_EXTENSION(vehicles, vehicles.cc car.cc, $ext_shared)
fi</textarea></div>
			<div class="crayon-main" style="">
				<table class="crayon-table">
					<tr class="crayon-row">
				<td class="crayon-nums " data-settings="show">
					<div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"><div class="crayon-num" data-line="crayon-55ebd96717b7d833008530-1">1</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b7d833008530-2">2</div><div class="crayon-num" data-line="crayon-55ebd96717b7d833008530-3">3</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b7d833008530-4">4</div><div class="crayon-num" data-line="crayon-55ebd96717b7d833008530-5">5</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b7d833008530-6">6</div><div class="crayon-num" data-line="crayon-55ebd96717b7d833008530-7">7</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b7d833008530-8">8</div><div class="crayon-num" data-line="crayon-55ebd96717b7d833008530-9">9</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b7d833008530-10">10</div></div>
				</td>
						<td class="crayon-code"><div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><div class="crayon-line" id="crayon-55ebd96717b7d833008530-1"><span class="crayon-e">PHP_ARG_ENABLE</span><span class="crayon-sy">(</span><span class="crayon-v">vehicles</span><span class="crayon-sy">,</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b7d833008530-2"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-sy">[</span><span class="crayon-e">Whether </span><span class="crayon-st">to</span><span class="crayon-h"> </span><span class="crayon-e">enable </span><span class="crayon-i">the</span><span class="crayon-h"> </span><span class="crayon-s">"vehicles"</span><span class="crayon-h"> </span><span class="crayon-v">extension</span><span class="crayon-sy">]</span><span class="crayon-sy">,</span></div><div class="crayon-line" id="crayon-55ebd96717b7d833008530-3"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-sy">[</span><span class="crayon-h">&nbsp;&nbsp;</span><span class="crayon-o">--</span><span class="crayon-v">enable</span><span class="crayon-o">-</span><span class="crayon-e">vehicles&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-i">Enable</span><span class="crayon-h"> </span><span class="crayon-s">"vehicles"</span><span class="crayon-h"> </span><span class="crayon-e">extension </span><span class="crayon-v">support</span><span class="crayon-sy">]</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b7d833008530-4">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717b7d833008530-5"><span class="crayon-st">if</span><span class="crayon-h"> </span><span class="crayon-i">test</span><span class="crayon-h"> </span><span class="crayon-sy">$</span><span class="crayon-v">PHP_VEHICLES</span><span class="crayon-h"> </span><span class="crayon-o">!=</span><span class="crayon-h"> </span><span class="crayon-s">"no"</span><span class="crayon-sy">;</span><span class="crayon-h"> </span><span class="crayon-st">then</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b7d833008530-6"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">PHP_REQUIRE_CXX</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-55ebd96717b7d833008530-7"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">PHP_SUBST</span><span class="crayon-sy">(</span><span class="crayon-v">VEHICLES_SHARED_LIBADD</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b7d833008530-8"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">PHP_ADD_LIBRARY</span><span class="crayon-sy">(</span><span class="crayon-v">stdc</span><span class="crayon-o">++</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-cn">1</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">VEHICLES_SHARED_LIBADD</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-55ebd96717b7d833008530-9"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">PHP_NEW_EXTENSION</span><span class="crayon-sy">(</span><span class="crayon-v">vehicles</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">vehicles</span><span class="crayon-sy">.</span><span class="crayon-e">cc </span><span class="crayon-v">car</span><span class="crayon-sy">.</span><span class="crayon-v">cc</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-sy">$</span><span class="crayon-v">ext_shared</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b7d833008530-10"><span class="crayon-v">fi</span></div></div></td>
					</tr>
				</table>
			</div>
		</div>
<!-- [Format Time: 0.0018 seconds] -->
<p></p>
<p>Depending on your compiler and how you compiled PHP, you may have to wrap your includes and certain macros in a linkage specification. If you’re not sure what that means, <a href="http://developers.sun.com/solaris/articles/mixing.html">this article</a> explains it nicely. So, together with all the usual skeleton code for a PHP extension, your php_vehicles.h header file should look something like this:</p>
<p></p><!-- Crayon Syntax Highlighter v2.7.1 -->

		<div id="crayon-55ebd96717b86158387502" class="crayon-syntax crayon-theme-bncplusplus crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
		
			<div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><span class="crayon-title"></span>
			<div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><div class="crayon-button crayon-nums-button" title="Toggle Line Numbers"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-plain-button" title="Toggle Plain Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-wrap-button" title="Toggle Line Wrap"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-expand-button" title="Expand Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-copy-button" title="Copy"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-popup-button" title="Open Code In New Window"><div class="crayon-button-icon"></div></div></div></div>
			<div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;"></div>
			<div class="crayon-plain-wrap"><textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">
#ifndef PHP_VEHICLES_H
#define PHP_VEHICLES_H

#define PHP_VEHICLES_EXTNAME  "vehicles"
#define PHP_VEHICLES_EXTVER   "0.1"

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif 

extern "C" {
#include "php.h"
}

extern zend_module_entry vehicles_module_entry;
#define phpext_vehicles_ptr &amp;vehicles_module_entry;

#endif /* PHP_VEHICLES_H */</textarea></div>
			<div class="crayon-main" style="">
				<table class="crayon-table">
					<tr class="crayon-row">
				<td class="crayon-nums " data-settings="show">
					<div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"><div class="crayon-num" data-line="crayon-55ebd96717b86158387502-1">1</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b86158387502-2">2</div><div class="crayon-num" data-line="crayon-55ebd96717b86158387502-3">3</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b86158387502-4">4</div><div class="crayon-num" data-line="crayon-55ebd96717b86158387502-5">5</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b86158387502-6">6</div><div class="crayon-num" data-line="crayon-55ebd96717b86158387502-7">7</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b86158387502-8">8</div><div class="crayon-num" data-line="crayon-55ebd96717b86158387502-9">9</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b86158387502-10">10</div><div class="crayon-num" data-line="crayon-55ebd96717b86158387502-11">11</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b86158387502-12">12</div><div class="crayon-num" data-line="crayon-55ebd96717b86158387502-13">13</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b86158387502-14">14</div><div class="crayon-num" data-line="crayon-55ebd96717b86158387502-15">15</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b86158387502-16">16</div><div class="crayon-num" data-line="crayon-55ebd96717b86158387502-17">17</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b86158387502-18">18</div></div>
				</td>
						<td class="crayon-code"><div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><div class="crayon-line" id="crayon-55ebd96717b86158387502-1"><span class="crayon-p">#ifndef PHP_VEHICLES_H</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b86158387502-2"><span class="crayon-p">#define PHP_VEHICLES_H</span></div><div class="crayon-line" id="crayon-55ebd96717b86158387502-3">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b86158387502-4"><span class="crayon-p">#define PHP_VEHICLES_EXTNAME&nbsp;&nbsp;"vehicles"</span></div><div class="crayon-line" id="crayon-55ebd96717b86158387502-5"><span class="crayon-p">#define PHP_VEHICLES_EXTVER&nbsp;&nbsp; "0.1"</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b86158387502-6">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717b86158387502-7"><span class="crayon-p">#ifdef HAVE_CONFIG_H</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b86158387502-8"><span class="crayon-p">#include "config.h"</span></div><div class="crayon-line" id="crayon-55ebd96717b86158387502-9"><span class="crayon-p">#endif </span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b86158387502-10">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717b86158387502-11"><span class="crayon-i">extern</span><span class="crayon-h"> </span><span class="crayon-s">"C"</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b86158387502-12"><span class="crayon-p">#include "php.h"</span></div><div class="crayon-line" id="crayon-55ebd96717b86158387502-13"><span class="crayon-sy">}</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b86158387502-14">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717b86158387502-15"><span class="crayon-e">extern </span><span class="crayon-e">zend_module_entry </span><span class="crayon-v">vehicles_module_entry</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b86158387502-16"><span class="crayon-p">#define phpext_vehicles_ptr &amp;vehicles_module_entry;</span></div><div class="crayon-line" id="crayon-55ebd96717b86158387502-17">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b86158387502-18"><span class="crayon-p">#endif /* PHP_VEHICLES_H */</span></div></div></td>
					</tr>
				</table>
			</div>
		</div>
<!-- [Format Time: 0.0006 seconds] -->
<p></p>
<p>Additionally, you’ll probably need to wrap the call to the ZEND_GET_MODULE() macro in vehicles.cc in a similar linkage specification. With that in mind, your vehicles.cc file should look like the following:</p>
<p></p><!-- Crayon Syntax Highlighter v2.7.1 -->

		<div id="crayon-55ebd96717b8b740055414" class="crayon-syntax crayon-theme-bncplusplus crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
		
			<div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><span class="crayon-title"></span>
			<div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><div class="crayon-button crayon-nums-button" title="Toggle Line Numbers"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-plain-button" title="Toggle Plain Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-wrap-button" title="Toggle Line Wrap"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-expand-button" title="Expand Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-copy-button" title="Copy"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-popup-button" title="Open Code In New Window"><div class="crayon-button-icon"></div></div></div></div>
			<div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;"></div>
			<div class="crayon-plain-wrap"><textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">
#include "php_vehicles.h"

PHP_MINIT_FUNCTION(vehicles)
{
    return SUCCESS;
}

zend_module_entry vehicles_module_entry = {
#if ZEND_MODULE_API_NO &gt;= 20010901
    STANDARD_MODULE_HEADER,
#endif
    PHP_VEHICLES_EXTNAME,
    NULL,                  /* Functions */
    PHP_MINIT(vehicles),
    NULL,                  /* MSHUTDOWN */
    NULL,                  /* RINIT */
    NULL,                  /* RSHUTDOWN */
    NULL,                  /* MINFO */
#if ZEND_MODULE_API_NO &gt;= 20010901
    PHP_VEHICLES_EXTVER,
#endif
    STANDARD_MODULE_PROPERTIES
};

#ifdef COMPILE_DL_VEHICLES
extern "C" {
ZEND_GET_MODULE(vehicles)
}
#endif</textarea></div>
			<div class="crayon-main" style="">
				<table class="crayon-table">
					<tr class="crayon-row">
				<td class="crayon-nums " data-settings="show">
					<div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"><div class="crayon-num" data-line="crayon-55ebd96717b8b740055414-1">1</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b8b740055414-2">2</div><div class="crayon-num" data-line="crayon-55ebd96717b8b740055414-3">3</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b8b740055414-4">4</div><div class="crayon-num" data-line="crayon-55ebd96717b8b740055414-5">5</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b8b740055414-6">6</div><div class="crayon-num" data-line="crayon-55ebd96717b8b740055414-7">7</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b8b740055414-8">8</div><div class="crayon-num" data-line="crayon-55ebd96717b8b740055414-9">9</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b8b740055414-10">10</div><div class="crayon-num" data-line="crayon-55ebd96717b8b740055414-11">11</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b8b740055414-12">12</div><div class="crayon-num" data-line="crayon-55ebd96717b8b740055414-13">13</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b8b740055414-14">14</div><div class="crayon-num" data-line="crayon-55ebd96717b8b740055414-15">15</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b8b740055414-16">16</div><div class="crayon-num" data-line="crayon-55ebd96717b8b740055414-17">17</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b8b740055414-18">18</div><div class="crayon-num" data-line="crayon-55ebd96717b8b740055414-19">19</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b8b740055414-20">20</div><div class="crayon-num" data-line="crayon-55ebd96717b8b740055414-21">21</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b8b740055414-22">22</div><div class="crayon-num" data-line="crayon-55ebd96717b8b740055414-23">23</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b8b740055414-24">24</div><div class="crayon-num" data-line="crayon-55ebd96717b8b740055414-25">25</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b8b740055414-26">26</div><div class="crayon-num" data-line="crayon-55ebd96717b8b740055414-27">27</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b8b740055414-28">28</div><div class="crayon-num" data-line="crayon-55ebd96717b8b740055414-29">29</div></div>
				</td>
						<td class="crayon-code"><div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><div class="crayon-line" id="crayon-55ebd96717b8b740055414-1"><span class="crayon-p">#include "php_vehicles.h"</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b8b740055414-2">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717b8b740055414-3"><span class="crayon-e">PHP_MINIT_FUNCTION</span><span class="crayon-sy">(</span><span class="crayon-v">vehicles</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b8b740055414-4"><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717b8b740055414-5"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-st">return</span><span class="crayon-h"> </span><span class="crayon-v">SUCCESS</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b8b740055414-6"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-55ebd96717b8b740055414-7">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b8b740055414-8"><span class="crayon-e">zend_module_entry </span><span class="crayon-v">vehicles_module_entry</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717b8b740055414-9"><span class="crayon-p">#if ZEND_MODULE_API_NO &gt;= 20010901</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b8b740055414-10"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">STANDARD_MODULE_HEADER</span><span class="crayon-sy">,</span></div><div class="crayon-line" id="crayon-55ebd96717b8b740055414-11"><span class="crayon-p">#endif</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b8b740055414-12"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">PHP_VEHICLES_EXTNAME</span><span class="crayon-sy">,</span></div><div class="crayon-line" id="crayon-55ebd96717b8b740055414-13"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-c">/* Functions */</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b8b740055414-14"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">PHP_MINIT</span><span class="crayon-sy">(</span><span class="crayon-v">vehicles</span><span class="crayon-sy">)</span><span class="crayon-sy">,</span></div><div class="crayon-line" id="crayon-55ebd96717b8b740055414-15"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-c">/* MSHUTDOWN */</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b8b740055414-16"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-c">/* RINIT */</span></div><div class="crayon-line" id="crayon-55ebd96717b8b740055414-17"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-c">/* RSHUTDOWN */</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b8b740055414-18"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-c">/* MINFO */</span></div><div class="crayon-line" id="crayon-55ebd96717b8b740055414-19"><span class="crayon-p">#if ZEND_MODULE_API_NO &gt;= 20010901</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b8b740055414-20"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">PHP_VEHICLES_EXTVER</span><span class="crayon-sy">,</span></div><div class="crayon-line" id="crayon-55ebd96717b8b740055414-21"><span class="crayon-p">#endif</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b8b740055414-22"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">STANDARD_MODULE</span><span class="crayon-sy">_</span>PROPERTIES</div><div class="crayon-line" id="crayon-55ebd96717b8b740055414-23"><span class="crayon-sy">}</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b8b740055414-24">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717b8b740055414-25"><span class="crayon-p">#ifdef COMPILE_DL_VEHICLES</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b8b740055414-26"><span class="crayon-i">extern</span><span class="crayon-h"> </span><span class="crayon-s">"C"</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717b8b740055414-27"><span class="crayon-e">ZEND_GET_MODULE</span><span class="crayon-sy">(</span><span class="crayon-v">vehicles</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b8b740055414-28"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-55ebd96717b8b740055414-29"><span class="crayon-p">#endif</span></div></div></td>
					</tr>
				</table>
			</div>
		</div>
<!-- [Format Time: 0.0019 seconds] -->
<p></p>
<p>Side Note: There is a set of macros provided with the PHP / Zend API called BEGIN_EXTERN_C / END_EXTERN_C but I don’t use them. They’re defined in Zend/zend.h which is included from php.h, so they’re not available when you need them in php_vehicles.h. In my opinion, the inconsistency of using macros in some places and not in others just isn’t worth the debatable aesthetic benefit you might obtain from using them.</p>
<p>At this point you can do a quick sanity check and make sure that your extension is compiling properly. Possible Gotchya: Even though we haven’t done anything with it yet, make sure that car.cc exists since we referred to it in config.m4 earlier. If the file does not exist, you will run into problems with this step.</p>
<p></p><!-- Crayon Syntax Highlighter v2.7.1 -->

		<div id="crayon-55ebd96717b90864057465" class="crayon-syntax crayon-theme-bncplusplus crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
		
			<div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><span class="crayon-title"></span>
			<div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><div class="crayon-button crayon-nums-button" title="Toggle Line Numbers"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-plain-button" title="Toggle Plain Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-wrap-button" title="Toggle Line Wrap"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-expand-button" title="Expand Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-copy-button" title="Copy"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-popup-button" title="Open Code In New Window"><div class="crayon-button-icon"></div></div></div></div>
			<div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;"></div>
			<div class="crayon-plain-wrap"><textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">
[paul@helm vehicles]$ phpize
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
[paul@helm vehicles]$ ./configure --enable-vehicles
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for gcc... gcc
checking for C compiler default output file name... a.out
...
[paul@helm vehicles]$ make
...
[paul@helm vehicles]$ sudo make install
...
[paul@helm vehicles]$ php -d"extension=vehicles.so" -m
[PHP Modules]
bcmath
bz2
calendar
ctype
tokenizer
vehicles
wddx

[Zend Modules]

[paul@helm vehicles]$</textarea></div>
			<div class="crayon-main" style="">
				<table class="crayon-table">
					<tr class="crayon-row">
				<td class="crayon-nums " data-settings="show">
					<div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"><div class="crayon-num" data-line="crayon-55ebd96717b90864057465-1">1</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b90864057465-2">2</div><div class="crayon-num" data-line="crayon-55ebd96717b90864057465-3">3</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b90864057465-4">4</div><div class="crayon-num" data-line="crayon-55ebd96717b90864057465-5">5</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b90864057465-6">6</div><div class="crayon-num" data-line="crayon-55ebd96717b90864057465-7">7</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b90864057465-8">8</div><div class="crayon-num" data-line="crayon-55ebd96717b90864057465-9">9</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b90864057465-10">10</div><div class="crayon-num" data-line="crayon-55ebd96717b90864057465-11">11</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b90864057465-12">12</div><div class="crayon-num" data-line="crayon-55ebd96717b90864057465-13">13</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b90864057465-14">14</div><div class="crayon-num" data-line="crayon-55ebd96717b90864057465-15">15</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b90864057465-16">16</div><div class="crayon-num" data-line="crayon-55ebd96717b90864057465-17">17</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b90864057465-18">18</div><div class="crayon-num" data-line="crayon-55ebd96717b90864057465-19">19</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b90864057465-20">20</div><div class="crayon-num" data-line="crayon-55ebd96717b90864057465-21">21</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b90864057465-22">22</div><div class="crayon-num" data-line="crayon-55ebd96717b90864057465-23">23</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b90864057465-24">24</div><div class="crayon-num" data-line="crayon-55ebd96717b90864057465-25">25</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b90864057465-26">26</div><div class="crayon-num" data-line="crayon-55ebd96717b90864057465-27">27</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b90864057465-28">28</div></div>
				</td>
						<td class="crayon-code"><div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><div class="crayon-line" id="crayon-55ebd96717b90864057465-1"><span class="crayon-sy">[</span><span class="crayon-v">paul</span><span class="crayon-sy">@</span><span class="crayon-e">helm </span><span class="crayon-v">vehicles</span><span class="crayon-sy">]</span><span class="crayon-sy">$</span><span class="crayon-h"> </span><span class="crayon-e">phpize</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b90864057465-2"><span class="crayon-e">PHP </span><span class="crayon-e">Api </span><span class="crayon-v">Version</span><span class="crayon-o">:</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-cn">20041225</span></div><div class="crayon-line" id="crayon-55ebd96717b90864057465-3"><span class="crayon-e">Zend </span><span class="crayon-e">Module </span><span class="crayon-e">Api </span><span class="crayon-v">No</span><span class="crayon-o">:</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-cn">20060613</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b90864057465-4"><span class="crayon-e">Zend </span><span class="crayon-e">Extension </span><span class="crayon-e">Api </span><span class="crayon-v">No</span><span class="crayon-o">:</span><span class="crayon-h">&nbsp;&nbsp; </span><span class="crayon-cn">220060519</span></div><div class="crayon-line" id="crayon-55ebd96717b90864057465-5"><span class="crayon-sy">[</span><span class="crayon-v">paul</span><span class="crayon-sy">@</span><span class="crayon-e">helm </span><span class="crayon-v">vehicles</span><span class="crayon-sy">]</span><span class="crayon-sy">$</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-o">/</span><span class="crayon-v">configure</span><span class="crayon-h"> </span><span class="crayon-o">--</span><span class="crayon-v">enable</span><span class="crayon-o">-</span><span class="crayon-e">vehicles</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b90864057465-6"><span class="crayon-e">checking </span><span class="crayon-st">for</span><span class="crayon-h"> </span><span class="crayon-e">grep </span><span class="crayon-e">that </span><span class="crayon-e">handles </span><span class="crayon-t">long</span><span class="crayon-h"> </span><span class="crayon-e">lines </span><span class="crayon-st">and</span><span class="crayon-h"> </span><span class="crayon-o">-</span><span class="crayon-v">e</span><span class="crayon-sy">.</span><span class="crayon-sy">.</span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-o">/</span><span class="crayon-v">bin</span><span class="crayon-o">/</span><span class="crayon-e">grep</span></div><div class="crayon-line" id="crayon-55ebd96717b90864057465-7"><span class="crayon-e">checking </span><span class="crayon-st">for</span><span class="crayon-h"> </span><span class="crayon-v">egrep</span><span class="crayon-sy">.</span><span class="crayon-sy">.</span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-o">/</span><span class="crayon-v">bin</span><span class="crayon-o">/</span><span class="crayon-v">grep</span><span class="crayon-h"> </span><span class="crayon-o">-</span><span class="crayon-i">E</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b90864057465-8"><span class="crayon-e">checking </span><span class="crayon-st">for</span><span class="crayon-h"> </span><span class="crayon-i">a</span><span class="crayon-h"> </span><span class="crayon-e">sed </span><span class="crayon-e">that </span><span class="crayon-e">does </span><span class="crayon-st">not</span><span class="crayon-h"> </span><span class="crayon-e">truncate </span><span class="crayon-v">output</span><span class="crayon-sy">.</span><span class="crayon-sy">.</span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-o">/</span><span class="crayon-v">bin</span><span class="crayon-o">/</span><span class="crayon-e">sed</span></div><div class="crayon-line" id="crayon-55ebd96717b90864057465-9"><span class="crayon-e">checking </span><span class="crayon-st">for</span><span class="crayon-h"> </span><span class="crayon-v">gcc</span><span class="crayon-sy">.</span><span class="crayon-sy">.</span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-e">gcc</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b90864057465-10"><span class="crayon-e">checking </span><span class="crayon-st">for</span><span class="crayon-h"> </span><span class="crayon-i">C</span><span class="crayon-h"> </span><span class="crayon-e">compiler </span><span class="crayon-st">default</span><span class="crayon-h"> </span><span class="crayon-e">output </span><span class="crayon-e">file </span><span class="crayon-v">name</span><span class="crayon-sy">.</span><span class="crayon-sy">.</span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-v">a</span><span class="crayon-sy">.</span><span class="crayon-i">out</span></div><div class="crayon-line" id="crayon-55ebd96717b90864057465-11"><span class="crayon-sy">.</span><span class="crayon-sy">.</span><span class="crayon-sy">.</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b90864057465-12"><span class="crayon-sy">[</span><span class="crayon-v">paul</span><span class="crayon-sy">@</span><span class="crayon-e">helm </span><span class="crayon-v">vehicles</span><span class="crayon-sy">]</span><span class="crayon-sy">$</span><span class="crayon-h"> </span><span class="crayon-i">make</span></div><div class="crayon-line" id="crayon-55ebd96717b90864057465-13"><span class="crayon-sy">.</span><span class="crayon-sy">.</span><span class="crayon-sy">.</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b90864057465-14"><span class="crayon-sy">[</span><span class="crayon-v">paul</span><span class="crayon-sy">@</span><span class="crayon-e">helm </span><span class="crayon-v">vehicles</span><span class="crayon-sy">]</span><span class="crayon-sy">$</span><span class="crayon-h"> </span><span class="crayon-e">sudo </span><span class="crayon-e">make </span><span class="crayon-i">install</span></div><div class="crayon-line" id="crayon-55ebd96717b90864057465-15"><span class="crayon-sy">.</span><span class="crayon-sy">.</span><span class="crayon-sy">.</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b90864057465-16"><span class="crayon-sy">[</span><span class="crayon-v">paul</span><span class="crayon-sy">@</span><span class="crayon-e">helm </span><span class="crayon-v">vehicles</span><span class="crayon-sy">]</span><span class="crayon-sy">$</span><span class="crayon-h"> </span><span class="crayon-v">php</span><span class="crayon-h"> </span><span class="crayon-o">-</span><span class="crayon-i">d</span><span class="crayon-s">"extension=vehicles.so"</span><span class="crayon-h"> </span><span class="crayon-o">-</span><span class="crayon-i">m</span></div><div class="crayon-line" id="crayon-55ebd96717b90864057465-17"><span class="crayon-sy">[</span><span class="crayon-e">PHP </span><span class="crayon-v">Modules</span><span class="crayon-sy">]</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b90864057465-18"><span class="crayon-e">bcmath</span></div><div class="crayon-line" id="crayon-55ebd96717b90864057465-19"><span class="crayon-e">bz2</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b90864057465-20"><span class="crayon-e">calendar</span></div><div class="crayon-line" id="crayon-55ebd96717b90864057465-21"><span class="crayon-e">ctype</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b90864057465-22"><span class="crayon-e">tokenizer</span></div><div class="crayon-line" id="crayon-55ebd96717b90864057465-23"><span class="crayon-e">vehicles</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b90864057465-24"><span class="crayon-i">wddx</span></div><div class="crayon-line" id="crayon-55ebd96717b90864057465-25">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b90864057465-26"><span class="crayon-sy">[</span><span class="crayon-e">Zend </span><span class="crayon-v">Modules</span><span class="crayon-sy">]</span></div><div class="crayon-line" id="crayon-55ebd96717b90864057465-27">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b90864057465-28"><span class="crayon-sy">[</span><span class="crayon-v">paul</span><span class="crayon-sy">@</span><span class="crayon-e">helm </span><span class="crayon-v">vehicles</span><span class="crayon-sy">]</span><span class="crayon-sy">$</span></div></div></td>
					</tr>
				</table>
			</div>
		</div>
<!-- [Format Time: 0.0039 seconds] -->
<p></p>
<p>I trimmed the output, but you get the idea. You should see the extension listed when you run php -m. Also replace sudo with whatever is appropriate for your system / setup. Maybe you’re doing this as a user who has permission to write to the php extension_dir or maybe you use &#8220;su -c&#8221; or something similar.</p>
<h2>The C++ Class</h2>
<p>Now that you have the basic skeleton of your extension and the PHP build system knows to use a C++ compiler to compile it, you can work on the class that you’re going to expose to PHP. Notice how I’ve kept the C++ class definition and implementation separate from any extension specific code? This isn’t strictly necessary, but it decreases coupling and is generally a good idea (if you want to reuse your C++ class, you can do so without pulling over any PHP extension cruft).</p>
<p>car.h:</p>
<p></p><!-- Crayon Syntax Highlighter v2.7.1 -->

		<div id="crayon-55ebd96717b96124999167" class="crayon-syntax crayon-theme-bncplusplus crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
		
			<div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><span class="crayon-title"></span>
			<div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><div class="crayon-button crayon-nums-button" title="Toggle Line Numbers"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-plain-button" title="Toggle Plain Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-wrap-button" title="Toggle Line Wrap"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-expand-button" title="Expand Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-copy-button" title="Copy"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-popup-button" title="Open Code In New Window"><div class="crayon-button-icon"></div></div></div></div>
			<div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;"></div>
			<div class="crayon-plain-wrap"><textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">
#ifndef VEHICLES_CAR_H
#define VEHICLES_CAR_H

// A very simple car class
class Car {
public:
    Car(int maxGear);
    void shift(int gear);
    void accelerate();
    void brake();
    int getCurrentSpeed();
    int getCurrentGear();
private:
    int maxGear;
    int currentGear;
    int speed;
};

#endif /* VEHICLES_CAR_H */</textarea></div>
			<div class="crayon-main" style="">
				<table class="crayon-table">
					<tr class="crayon-row">
				<td class="crayon-nums " data-settings="show">
					<div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"><div class="crayon-num" data-line="crayon-55ebd96717b96124999167-1">1</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b96124999167-2">2</div><div class="crayon-num" data-line="crayon-55ebd96717b96124999167-3">3</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b96124999167-4">4</div><div class="crayon-num" data-line="crayon-55ebd96717b96124999167-5">5</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b96124999167-6">6</div><div class="crayon-num" data-line="crayon-55ebd96717b96124999167-7">7</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b96124999167-8">8</div><div class="crayon-num" data-line="crayon-55ebd96717b96124999167-9">9</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b96124999167-10">10</div><div class="crayon-num" data-line="crayon-55ebd96717b96124999167-11">11</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b96124999167-12">12</div><div class="crayon-num" data-line="crayon-55ebd96717b96124999167-13">13</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b96124999167-14">14</div><div class="crayon-num" data-line="crayon-55ebd96717b96124999167-15">15</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b96124999167-16">16</div><div class="crayon-num" data-line="crayon-55ebd96717b96124999167-17">17</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b96124999167-18">18</div><div class="crayon-num" data-line="crayon-55ebd96717b96124999167-19">19</div></div>
				</td>
						<td class="crayon-code"><div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><div class="crayon-line" id="crayon-55ebd96717b96124999167-1"><span class="crayon-p">#ifndef VEHICLES_CAR_H</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b96124999167-2"><span class="crayon-p">#define VEHICLES_CAR_H</span></div><div class="crayon-line" id="crayon-55ebd96717b96124999167-3">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b96124999167-4"><span class="crayon-c">// A very simple car class</span></div><div class="crayon-line" id="crayon-55ebd96717b96124999167-5"><span class="crayon-t">class</span><span class="crayon-h"> </span><span class="crayon-e">Car</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b96124999167-6"><span class="crayon-m">public</span><span class="crayon-o">:</span></div><div class="crayon-line" id="crayon-55ebd96717b96124999167-7"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">Car</span><span class="crayon-sy">(</span><span class="crayon-t">int</span><span class="crayon-h"> </span><span class="crayon-v">maxGear</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b96124999167-8"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">void</span><span class="crayon-h"> </span><span class="crayon-e">shift</span><span class="crayon-sy">(</span><span class="crayon-t">int</span><span class="crayon-h"> </span><span class="crayon-v">gear</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717b96124999167-9"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">void</span><span class="crayon-h"> </span><span class="crayon-e">accelerate</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b96124999167-10"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">void</span><span class="crayon-h"> </span><span class="crayon-e">brake</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717b96124999167-11"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">int</span><span class="crayon-h"> </span><span class="crayon-e">getCurrentSpeed</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b96124999167-12"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">int</span><span class="crayon-h"> </span><span class="crayon-e">getCurrentGear</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717b96124999167-13"><span class="crayon-m">private</span><span class="crayon-o">:</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b96124999167-14"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">int</span><span class="crayon-h"> </span><span class="crayon-v">maxGear</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717b96124999167-15"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">int</span><span class="crayon-h"> </span><span class="crayon-v">currentGear</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b96124999167-16"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">int</span><span class="crayon-h"> </span><span class="crayon-v">speed</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717b96124999167-17"><span class="crayon-sy">}</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b96124999167-18">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717b96124999167-19"><span class="crayon-p">#endif /* VEHICLES_CAR_H */</span></div></div></td>
					</tr>
				</table>
			</div>
		</div>
<!-- [Format Time: 0.0016 seconds] -->
<p></p>
<p>car.cc:</p>
<p></p><!-- Crayon Syntax Highlighter v2.7.1 -->

		<div id="crayon-55ebd96717b9a187658879" class="crayon-syntax crayon-theme-bncplusplus crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
		
			<div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><span class="crayon-title"></span>
			<div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><div class="crayon-button crayon-nums-button" title="Toggle Line Numbers"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-plain-button" title="Toggle Plain Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-wrap-button" title="Toggle Line Wrap"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-expand-button" title="Expand Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-copy-button" title="Copy"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-popup-button" title="Open Code In New Window"><div class="crayon-button-icon"></div></div></div></div>
			<div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;"></div>
			<div class="crayon-plain-wrap"><textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">
#include "car.h"

Car::Car(int maxGear) {
    this-&gt;maxGear = maxGear;
    this-&gt;currentGear = 1;
    this-&gt;speed = 0;
}

void Car::shift(int gear) {
    if (gear &lt; 1 || gear &gt; maxGear) {
        return;
    }
    currentGear = gear;
}

void Car::accelerate() {
    speed += (5 * this-&gt;getCurrentGear());
}

void Car::brake() {
    speed -= (5 * this-&gt;getCurrentGear());
}

int Car::getCurrentSpeed() {
    return speed;
}

int Car::getCurrentGear() {
    return currentGear;
}</textarea></div>
			<div class="crayon-main" style="">
				<table class="crayon-table">
					<tr class="crayon-row">
				<td class="crayon-nums " data-settings="show">
					<div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"><div class="crayon-num" data-line="crayon-55ebd96717b9a187658879-1">1</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9a187658879-2">2</div><div class="crayon-num" data-line="crayon-55ebd96717b9a187658879-3">3</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9a187658879-4">4</div><div class="crayon-num" data-line="crayon-55ebd96717b9a187658879-5">5</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9a187658879-6">6</div><div class="crayon-num" data-line="crayon-55ebd96717b9a187658879-7">7</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9a187658879-8">8</div><div class="crayon-num" data-line="crayon-55ebd96717b9a187658879-9">9</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9a187658879-10">10</div><div class="crayon-num" data-line="crayon-55ebd96717b9a187658879-11">11</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9a187658879-12">12</div><div class="crayon-num" data-line="crayon-55ebd96717b9a187658879-13">13</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9a187658879-14">14</div><div class="crayon-num" data-line="crayon-55ebd96717b9a187658879-15">15</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9a187658879-16">16</div><div class="crayon-num" data-line="crayon-55ebd96717b9a187658879-17">17</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9a187658879-18">18</div><div class="crayon-num" data-line="crayon-55ebd96717b9a187658879-19">19</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9a187658879-20">20</div><div class="crayon-num" data-line="crayon-55ebd96717b9a187658879-21">21</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9a187658879-22">22</div><div class="crayon-num" data-line="crayon-55ebd96717b9a187658879-23">23</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9a187658879-24">24</div><div class="crayon-num" data-line="crayon-55ebd96717b9a187658879-25">25</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9a187658879-26">26</div><div class="crayon-num" data-line="crayon-55ebd96717b9a187658879-27">27</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9a187658879-28">28</div><div class="crayon-num" data-line="crayon-55ebd96717b9a187658879-29">29</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9a187658879-30">30</div></div>
				</td>
						<td class="crayon-code"><div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><div class="crayon-line" id="crayon-55ebd96717b9a187658879-1"><span class="crayon-p">#include "car.h"</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9a187658879-2">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717b9a187658879-3"><span class="crayon-v">Car</span><span class="crayon-o">::</span><span class="crayon-e">Car</span><span class="crayon-sy">(</span><span class="crayon-t">int</span><span class="crayon-h"> </span><span class="crayon-v">maxGear</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9a187658879-4"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-r">this</span><span class="crayon-o">-&gt;</span><span class="crayon-v">maxGear</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-v">maxGear</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717b9a187658879-5"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-r">this</span><span class="crayon-o">-&gt;</span><span class="crayon-v">currentGear</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-cn">1</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9a187658879-6"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-r">this</span><span class="crayon-o">-&gt;</span><span class="crayon-v">speed</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-cn">0</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717b9a187658879-7"><span class="crayon-sy">}</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9a187658879-8">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717b9a187658879-9"><span class="crayon-t">void</span><span class="crayon-h"> </span><span class="crayon-v">Car</span><span class="crayon-o">::</span><span class="crayon-e">shift</span><span class="crayon-sy">(</span><span class="crayon-t">int</span><span class="crayon-h"> </span><span class="crayon-v">gear</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9a187658879-10"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-st">if</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-v">gear</span><span class="crayon-h"> </span><span class="crayon-o">&lt;</span><span class="crayon-h"> </span><span class="crayon-cn">1</span><span class="crayon-h"> </span><span class="crayon-o">||</span><span class="crayon-h"> </span><span class="crayon-v">gear</span><span class="crayon-h"> </span><span class="crayon-o">&gt;</span><span class="crayon-h"> </span><span class="crayon-v">maxGear</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717b9a187658879-11"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-st">return</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9a187658879-12"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-55ebd96717b9a187658879-13"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">currentGear</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-v">gear</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9a187658879-14"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-55ebd96717b9a187658879-15">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9a187658879-16"><span class="crayon-t">void</span><span class="crayon-h"> </span><span class="crayon-v">Car</span><span class="crayon-o">::</span><span class="crayon-e">accelerate</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717b9a187658879-17"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">speed</span><span class="crayon-h"> </span><span class="crayon-o">+=</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-cn">5</span><span class="crayon-h"> </span><span class="crayon-o">*</span><span class="crayon-h"> </span><span class="crayon-r">this</span><span class="crayon-o">-&gt;</span><span class="crayon-e">getCurrentGear</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9a187658879-18"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-55ebd96717b9a187658879-19">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9a187658879-20"><span class="crayon-t">void</span><span class="crayon-h"> </span><span class="crayon-v">Car</span><span class="crayon-o">::</span><span class="crayon-e">brake</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717b9a187658879-21"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">speed</span><span class="crayon-h"> </span><span class="crayon-o">-=</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-cn">5</span><span class="crayon-h"> </span><span class="crayon-o">*</span><span class="crayon-h"> </span><span class="crayon-r">this</span><span class="crayon-o">-&gt;</span><span class="crayon-e">getCurrentGear</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9a187658879-22"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-55ebd96717b9a187658879-23">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9a187658879-24"><span class="crayon-t">int</span><span class="crayon-h"> </span><span class="crayon-v">Car</span><span class="crayon-o">::</span><span class="crayon-e">getCurrentSpeed</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717b9a187658879-25"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-st">return</span><span class="crayon-h"> </span><span class="crayon-v">speed</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9a187658879-26"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-55ebd96717b9a187658879-27">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9a187658879-28"><span class="crayon-t">int</span><span class="crayon-h"> </span><span class="crayon-v">Car</span><span class="crayon-o">::</span><span class="crayon-e">getCurrentGear</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717b9a187658879-29"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-st">return</span><span class="crayon-h"> </span><span class="crayon-v">currentGear</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9a187658879-30"><span class="crayon-sy">}</span></div></div></td>
					</tr>
				</table>
			</div>
		</div>
<!-- [Format Time: 0.0032 seconds] -->
<p></p>
<p>In order to expose this class to PHP userspace scripts, you’ll first need to define a PHP class called Car with a function_entry table that contains a method for each of the C++ class methods you wish to expose. I should point out that the PHP class does not need to have the same name as the C++ class, and it is completely feasible to include methods in your PHP class that do not exist in your C++ class and vice versa. Again, I’m striving for simplicity here so I’ve kept the class names the same and I’ve maintained a 1-to-1 mapping of C++ and PHP methods. Update vehicles.cc to contain the following:</p>
<p></p><!-- Crayon Syntax Highlighter v2.7.1 -->

		<div id="crayon-55ebd96717b9e950980410" class="crayon-syntax crayon-theme-bncplusplus crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
		
			<div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><span class="crayon-title"></span>
			<div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><div class="crayon-button crayon-nums-button" title="Toggle Line Numbers"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-plain-button" title="Toggle Plain Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-wrap-button" title="Toggle Line Wrap"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-expand-button" title="Expand Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-copy-button" title="Copy"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-popup-button" title="Open Code In New Window"><div class="crayon-button-icon"></div></div></div></div>
			<div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;"></div>
			<div class="crayon-plain-wrap"><textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">
#include "php_vehicles.h"

zend_class_entry *car_ce;

PHP_METHOD(Car, __construct)
{
}
PHP_METHOD(Car, shift)
{
}
PHP_METHOD(Car, accelerate)
{
}
PHP_METHOD(Car, brake)
{
}
PHP_METHOD(Car, getCurrentSpeed)
{
}
PHP_METHOD(Car, getCurrentGear)
{
}

function_entry car_methods[] = {
    PHP_ME(Car,  __construct,     NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
    PHP_ME(Car,  shift,           NULL, ZEND_ACC_PUBLIC)
    PHP_ME(Car,  accelerate,      NULL, ZEND_ACC_PUBLIC)
    PHP_ME(Car,  brake,           NULL, ZEND_ACC_PUBLIC)
    PHP_ME(Car,  getCurrentSpeed, NULL, ZEND_ACC_PUBLIC)
    PHP_ME(Car,  getCurrentGear,  NULL, ZEND_ACC_PUBLIC)
    {NULL, NULL, NULL}
};

PHP_MINIT_FUNCTION(vehicles)
{
    zend_class_entry ce;
    INIT_CLASS_ENTRY(ce, "Car", car_methods);
    car_ce = zend_register_internal_class(&amp;ce TSRMLS_CC);
    return SUCCESS;
}

zend_module_entry vehicles_module_entry = {
#if ZEND_MODULE_API_NO &gt;= 20010901
    STANDARD_MODULE_HEADER,
#endif
    PHP_VEHICLES_EXTNAME,
    NULL,        /* Functions */
    PHP_MINIT(vehicles),        /* MINIT */
    NULL,        /* MSHUTDOWN */
    NULL,        /* RINIT */
    NULL,        /* RSHUTDOWN */
    NULL,        /* MINFO */
#if ZEND_MODULE_API_NO &gt;= 20010901
    PHP_VEHICLES_EXTVER,
#endif
    STANDARD_MODULE_PROPERTIES
};

#ifdef COMPILE_DL_VEHICLES
extern "C" {
ZEND_GET_MODULE(vehicles)
}
#endif</textarea></div>
			<div class="crayon-main" style="">
				<table class="crayon-table">
					<tr class="crayon-row">
				<td class="crayon-nums " data-settings="show">
					<div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-1">1</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-2">2</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-3">3</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-4">4</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-5">5</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-6">6</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-7">7</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-8">8</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-9">9</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-10">10</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-11">11</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-12">12</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-13">13</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-14">14</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-15">15</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-16">16</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-17">17</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-18">18</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-19">19</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-20">20</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-21">21</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-22">22</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-23">23</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-24">24</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-25">25</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-26">26</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-27">27</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-28">28</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-29">29</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-30">30</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-31">31</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-32">32</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-33">33</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-34">34</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-35">35</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-36">36</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-37">37</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-38">38</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-39">39</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-40">40</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-41">41</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-42">42</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-43">43</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-44">44</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-45">45</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-46">46</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-47">47</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-48">48</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-49">49</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-50">50</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-51">51</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-52">52</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-53">53</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-54">54</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-55">55</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-56">56</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-57">57</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-58">58</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-59">59</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-60">60</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-61">61</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717b9e950980410-62">62</div><div class="crayon-num" data-line="crayon-55ebd96717b9e950980410-63">63</div></div>
				</td>
						<td class="crayon-code"><div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><div class="crayon-line" id="crayon-55ebd96717b9e950980410-1"><span class="crayon-p">#include "php_vehicles.h"</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-2">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-3"><span class="crayon-e ">zend_class_entry *</span><span class="crayon-v">car_ce</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-4">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-5"><span class="crayon-e">PHP_METHOD</span><span class="crayon-sy">(</span><span class="crayon-v">Car</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">__construct</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-6"><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-7"><span class="crayon-sy">}</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-8"><span class="crayon-e">PHP_METHOD</span><span class="crayon-sy">(</span><span class="crayon-v">Car</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">shift</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-9"><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-10"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-11"><span class="crayon-e">PHP_METHOD</span><span class="crayon-sy">(</span><span class="crayon-v">Car</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">accelerate</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-12"><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-13"><span class="crayon-sy">}</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-14"><span class="crayon-e">PHP_METHOD</span><span class="crayon-sy">(</span><span class="crayon-v">Car</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">brake</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-15"><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-16"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-17"><span class="crayon-e">PHP_METHOD</span><span class="crayon-sy">(</span><span class="crayon-v">Car</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">getCurrentSpeed</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-18"><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-19"><span class="crayon-sy">}</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-20"><span class="crayon-e">PHP_METHOD</span><span class="crayon-sy">(</span><span class="crayon-v">Car</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">getCurrentGear</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-21"><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-22"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-23">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-24"><span class="crayon-e">function_entry </span><span class="crayon-v">car_methods</span><span class="crayon-sy">[</span><span class="crayon-sy">]</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-25"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">PHP_ME</span><span class="crayon-sy">(</span><span class="crayon-v">Car</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;</span><span class="crayon-v">__construct</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">ZEND_ACC_PUBLIC</span><span class="crayon-h"> </span><span class="crayon-o">|</span><span class="crayon-h"> </span><span class="crayon-v">ZEND_ACC_CTOR</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-26"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">PHP_ME</span><span class="crayon-sy">(</span><span class="crayon-v">Car</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;</span><span class="crayon-v">shift</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">ZEND_ACC_PUBLIC</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-27"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">PHP_ME</span><span class="crayon-sy">(</span><span class="crayon-v">Car</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;</span><span class="crayon-v">accelerate</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">ZEND_ACC_PUBLIC</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-28"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">PHP_ME</span><span class="crayon-sy">(</span><span class="crayon-v">Car</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;</span><span class="crayon-v">brake</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">ZEND_ACC_PUBLIC</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-29"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">PHP_ME</span><span class="crayon-sy">(</span><span class="crayon-v">Car</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;</span><span class="crayon-v">getCurrentSpeed</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">ZEND_ACC_PUBLIC</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-30"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">PHP_ME</span><span class="crayon-sy">(</span><span class="crayon-v">Car</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;</span><span class="crayon-v">getCurrentGear</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;</span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">ZEND_ACC_PUBLIC</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-31"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-sy">{</span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-t">NULL</span><span class="crayon-sy">}</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-32"><span class="crayon-sy">}</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-33">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-34"><span class="crayon-e">PHP_MINIT_FUNCTION</span><span class="crayon-sy">(</span><span class="crayon-v">vehicles</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-35"><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-36"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">zend_class_entry </span><span class="crayon-v">ce</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-37"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">INIT_CLASS_ENTRY</span><span class="crayon-sy">(</span><span class="crayon-v">ce</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-s">"Car"</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">car_methods</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-38"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">car_ce</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-e">zend_register_internal_class</span><span class="crayon-sy">(</span><span class="crayon-o">&amp;</span><span class="crayon-e">ce </span><span class="crayon-v">TSRMLS_CC</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-39"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-st">return</span><span class="crayon-h"> </span><span class="crayon-v">SUCCESS</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-40"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-41">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-42"><span class="crayon-e">zend_module_entry </span><span class="crayon-v">vehicles_module_entry</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-43"><span class="crayon-p">#if ZEND_MODULE_API_NO &gt;= 20010901</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-44"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">STANDARD_MODULE_HEADER</span><span class="crayon-sy">,</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-45"><span class="crayon-p">#endif</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-46"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">PHP_VEHICLES_EXTNAME</span><span class="crayon-sy">,</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-47"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-c">/* Functions */</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-48"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">PHP_MINIT</span><span class="crayon-sy">(</span><span class="crayon-v">vehicles</span><span class="crayon-sy">)</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-c">/* MINIT */</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-49"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-c">/* MSHUTDOWN */</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-50"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-c">/* RINIT */</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-51"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-c">/* RSHUTDOWN */</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-52"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-c">/* MINFO */</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-53"><span class="crayon-p">#if ZEND_MODULE_API_NO &gt;= 20010901</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-54"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">PHP_VEHICLES_EXTVER</span><span class="crayon-sy">,</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-55"><span class="crayon-p">#endif</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-56"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">STANDARD_MODULE</span><span class="crayon-sy">_</span>PROPERTIES</div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-57"><span class="crayon-sy">}</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-58">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-59"><span class="crayon-p">#ifdef COMPILE_DL_VEHICLES</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-60"><span class="crayon-i">extern</span><span class="crayon-h"> </span><span class="crayon-s">"C"</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-61"><span class="crayon-e">ZEND_GET_MODULE</span><span class="crayon-sy">(</span><span class="crayon-v">vehicles</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717b9e950980410-62"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-55ebd96717b9e950980410-63"><span class="crayon-p">#endif</span></div></div></td>
					</tr>
				</table>
			</div>
		</div>
<!-- [Format Time: 0.0057 seconds] -->
<p></p>
<p>If this is looking a little foreign to you, I recommend reading Chapters 10 and 11 of &#8220;Extending PHP&#8221;.</p>
<h2>Connecting the Dots</h2>
<p>At this point you have a C++ class and a PHP class with identical (or similar) definitions. Now you need to connect the two. Each instance of the PHP class must have access to exactly one instance of the C++ class. One way to do this is to use a struct to keep track of the C++ and the PHP instances. Doing so requires that you implement your own object handlers. Remember that in PHP5, an object is just a handle (a unique id that allows the Zend Engine to locate your class), a method table, and a set of handlers. You can override handlers to perform the various tasks that need to be performed at various stages of the object’s lifecycle. Add the following to the top your vehicles.cc file:</p>
<p></p><!-- Crayon Syntax Highlighter v2.7.1 -->

		<div id="crayon-55ebd96717ba4111162167" class="crayon-syntax crayon-theme-bncplusplus crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
		
			<div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><span class="crayon-title"></span>
			<div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><div class="crayon-button crayon-nums-button" title="Toggle Line Numbers"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-plain-button" title="Toggle Plain Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-wrap-button" title="Toggle Line Wrap"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-expand-button" title="Expand Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-copy-button" title="Copy"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-popup-button" title="Open Code In New Window"><div class="crayon-button-icon"></div></div></div></div>
			<div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;"></div>
			<div class="crayon-plain-wrap"><textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">
#include "car.h"

zend_object_handlers car_object_handlers;

struct car_object {
    zend_object std;
    Car *car;
};</textarea></div>
			<div class="crayon-main" style="">
				<table class="crayon-table">
					<tr class="crayon-row">
				<td class="crayon-nums " data-settings="show">
					<div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"><div class="crayon-num" data-line="crayon-55ebd96717ba4111162167-1">1</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba4111162167-2">2</div><div class="crayon-num" data-line="crayon-55ebd96717ba4111162167-3">3</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba4111162167-4">4</div><div class="crayon-num" data-line="crayon-55ebd96717ba4111162167-5">5</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba4111162167-6">6</div><div class="crayon-num" data-line="crayon-55ebd96717ba4111162167-7">7</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba4111162167-8">8</div></div>
				</td>
						<td class="crayon-code"><div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><div class="crayon-line" id="crayon-55ebd96717ba4111162167-1"><span class="crayon-p">#include "car.h"</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba4111162167-2">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717ba4111162167-3"><span class="crayon-e">zend_object_handlers </span><span class="crayon-v">car_object_handlers</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba4111162167-4">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717ba4111162167-5"><span class="crayon-t">struct</span><span class="crayon-h"> </span><span class="crayon-e">car_object</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba4111162167-6"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">zend_object </span><span class="crayon-v">std</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717ba4111162167-7"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e ">Car *</span><span class="crayon-v">car</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba4111162167-8"><span class="crayon-sy">}</span><span class="crayon-sy">;</span></div></div></td>
					</tr>
				</table>
			</div>
		</div>
<!-- [Format Time: 0.0005 seconds] -->
<p></p>
<p>The car_object structure will be used to keep track of our C++ instances, associating them to a zend_object. Add the following functions to your vehicles.cc file, above the PHP_METHOD declarations:</p>
<p></p><!-- Crayon Syntax Highlighter v2.7.1 -->

		<div id="crayon-55ebd96717ba8090281587" class="crayon-syntax crayon-theme-bncplusplus crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
		
			<div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><span class="crayon-title"></span>
			<div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><div class="crayon-button crayon-nums-button" title="Toggle Line Numbers"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-plain-button" title="Toggle Plain Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-wrap-button" title="Toggle Line Wrap"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-expand-button" title="Expand Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-copy-button" title="Copy"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-popup-button" title="Open Code In New Window"><div class="crayon-button-icon"></div></div></div></div>
			<div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;"></div>
			<div class="crayon-plain-wrap"><textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">
void car_free_storage(void *object TSRMLS_DC)
{
    car_object *obj = (car_object *)object;
    delete obj-&gt;car; 

    zend_hash_destroy(obj-&gt;std.properties);
    FREE_HASHTABLE(obj-&gt;std.properties);

    efree(obj);
}

zend_object_value car_create_handler(zend_class_entry *type TSRMLS_DC)
{
    zval *tmp;
    zend_object_value retval;

    car_object *obj = (car_object *)emalloc(sizeof(car_object));
    memset(obj, 0, sizeof(car_object));
    obj-&gt;std.ce = type;

    ALLOC_HASHTABLE(obj-&gt;std.properties);
    zend_hash_init(obj-&gt;std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
    zend_hash_copy(obj-&gt;std.properties, &amp;type-&gt;default_properties,
        (copy_ctor_func_t)zval_add_ref, (void *)&amp;tmp, sizeof(zval *));

    retval.handle = zend_objects_store_put(obj, NULL,
        car_free_storage, NULL TSRMLS_CC);
    retval.handlers = &amp;car_object_handlers;

    return retval;
}</textarea></div>
			<div class="crayon-main" style="">
				<table class="crayon-table">
					<tr class="crayon-row">
				<td class="crayon-nums " data-settings="show">
					<div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"><div class="crayon-num" data-line="crayon-55ebd96717ba8090281587-1">1</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba8090281587-2">2</div><div class="crayon-num" data-line="crayon-55ebd96717ba8090281587-3">3</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba8090281587-4">4</div><div class="crayon-num" data-line="crayon-55ebd96717ba8090281587-5">5</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba8090281587-6">6</div><div class="crayon-num" data-line="crayon-55ebd96717ba8090281587-7">7</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba8090281587-8">8</div><div class="crayon-num" data-line="crayon-55ebd96717ba8090281587-9">9</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba8090281587-10">10</div><div class="crayon-num" data-line="crayon-55ebd96717ba8090281587-11">11</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba8090281587-12">12</div><div class="crayon-num" data-line="crayon-55ebd96717ba8090281587-13">13</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba8090281587-14">14</div><div class="crayon-num" data-line="crayon-55ebd96717ba8090281587-15">15</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba8090281587-16">16</div><div class="crayon-num" data-line="crayon-55ebd96717ba8090281587-17">17</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba8090281587-18">18</div><div class="crayon-num" data-line="crayon-55ebd96717ba8090281587-19">19</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba8090281587-20">20</div><div class="crayon-num" data-line="crayon-55ebd96717ba8090281587-21">21</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba8090281587-22">22</div><div class="crayon-num" data-line="crayon-55ebd96717ba8090281587-23">23</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba8090281587-24">24</div><div class="crayon-num" data-line="crayon-55ebd96717ba8090281587-25">25</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba8090281587-26">26</div><div class="crayon-num" data-line="crayon-55ebd96717ba8090281587-27">27</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba8090281587-28">28</div><div class="crayon-num" data-line="crayon-55ebd96717ba8090281587-29">29</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717ba8090281587-30">30</div><div class="crayon-num" data-line="crayon-55ebd96717ba8090281587-31">31</div></div>
				</td>
						<td class="crayon-code"><div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><div class="crayon-line" id="crayon-55ebd96717ba8090281587-1"><span class="crayon-t">void</span><span class="crayon-h"> </span><span class="crayon-e">car_free_storage</span><span class="crayon-sy">(</span><span class="crayon-t">void</span><span class="crayon-h"> </span><span class="crayon-o">*</span><span class="crayon-t">object</span><span class="crayon-h"> </span><span class="crayon-v">TSRMLS_DC</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba8090281587-2"><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717ba8090281587-3"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e ">car_object *</span><span class="crayon-v">obj</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-e ">car_object *</span><span class="crayon-sy">)</span><span class="crayon-t">object</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba8090281587-4"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">delete </span><span class="crayon-v">obj</span><span class="crayon-o">-&gt;</span><span class="crayon-v">car</span><span class="crayon-sy">;</span><span class="crayon-h"> </span></div><div class="crayon-line" id="crayon-55ebd96717ba8090281587-5">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba8090281587-6"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">zend_hash_destroy</span><span class="crayon-sy">(</span><span class="crayon-v">obj</span><span class="crayon-o">-&gt;</span><span class="crayon-v">std</span><span class="crayon-sy">.</span><span class="crayon-v">properties</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717ba8090281587-7"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">FREE_HASHTABLE</span><span class="crayon-sy">(</span><span class="crayon-v">obj</span><span class="crayon-o">-&gt;</span><span class="crayon-v">std</span><span class="crayon-sy">.</span><span class="crayon-v">properties</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba8090281587-8">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717ba8090281587-9"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">efree</span><span class="crayon-sy">(</span><span class="crayon-v">obj</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba8090281587-10"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-55ebd96717ba8090281587-11">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba8090281587-12"><span class="crayon-e">zend_object_value </span><span class="crayon-e">car_create_handler</span><span class="crayon-sy">(</span><span class="crayon-e ">zend_class_entry *</span><span class="crayon-e">type </span><span class="crayon-v">TSRMLS_DC</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-55ebd96717ba8090281587-13"><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba8090281587-14"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e ">zval *</span><span class="crayon-v">tmp</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717ba8090281587-15"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">zend_object_value </span><span class="crayon-v">retval</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba8090281587-16">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717ba8090281587-17"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e ">car_object *</span><span class="crayon-v">obj</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-e ">car_object *</span><span class="crayon-sy">)</span><span class="crayon-e">emalloc</span><span class="crayon-sy">(</span><span class="crayon-e">sizeof</span><span class="crayon-sy">(</span><span class="crayon-v">car_object</span><span class="crayon-sy">)</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba8090281587-18"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">memset</span><span class="crayon-sy">(</span><span class="crayon-v">obj</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-cn">0</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-e">sizeof</span><span class="crayon-sy">(</span><span class="crayon-v">car_object</span><span class="crayon-sy">)</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717ba8090281587-19"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">obj</span><span class="crayon-o">-&gt;</span><span class="crayon-v">std</span><span class="crayon-sy">.</span><span class="crayon-v">ce</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-v">type</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba8090281587-20">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717ba8090281587-21"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">ALLOC_HASHTABLE</span><span class="crayon-sy">(</span><span class="crayon-v">obj</span><span class="crayon-o">-&gt;</span><span class="crayon-v">std</span><span class="crayon-sy">.</span><span class="crayon-v">properties</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba8090281587-22"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">zend_hash_init</span><span class="crayon-sy">(</span><span class="crayon-v">obj</span><span class="crayon-o">-&gt;</span><span class="crayon-v">std</span><span class="crayon-sy">.</span><span class="crayon-v">properties</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-cn">0</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">ZVAL_PTR_DTOR</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-cn">0</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717ba8090281587-23"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">zend_hash_copy</span><span class="crayon-sy">(</span><span class="crayon-v">obj</span><span class="crayon-o">-&gt;</span><span class="crayon-v">std</span><span class="crayon-sy">.</span><span class="crayon-v">properties</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-o">&amp;</span><span class="crayon-v">type</span><span class="crayon-o">-&gt;</span><span class="crayon-v">default_properties</span><span class="crayon-sy">,</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba8090281587-24"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-sy">(</span><span class="crayon-v">copy_ctor_func_t</span><span class="crayon-sy">)</span><span class="crayon-v">zval_add_ref</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-t">void</span><span class="crayon-h"> </span><span class="crayon-o">*</span><span class="crayon-sy">)</span><span class="crayon-o">&amp;</span><span class="crayon-v">tmp</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-e">sizeof</span><span class="crayon-sy">(</span><span class="crayon-e ">zval *</span><span class="crayon-sy">)</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717ba8090281587-25">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba8090281587-26"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">retval</span><span class="crayon-sy">.</span><span class="crayon-v">handle</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-e">zend_objects_store_put</span><span class="crayon-sy">(</span><span class="crayon-v">obj</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-t">NULL</span><span class="crayon-sy">,</span></div><div class="crayon-line" id="crayon-55ebd96717ba8090281587-27"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">car_free_storage</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-t">NULL</span><span class="crayon-h"> </span><span class="crayon-v">TSRMLS_CC</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba8090281587-28"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">retval</span><span class="crayon-sy">.</span><span class="crayon-v">handlers</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-o">&amp;</span><span class="crayon-v">car_object_handlers</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717ba8090281587-29">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717ba8090281587-30"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-st">return</span><span class="crayon-h"> </span><span class="crayon-v">retval</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717ba8090281587-31"><span class="crayon-sy">}</span></div></div></td>
					</tr>
				</table>
			</div>
		</div>
<!-- [Format Time: 0.0044 seconds] -->
<p></p>
<p>And update your PHP_MINIT_FUNCTION in vehicles.cc:</p>
<p></p><!-- Crayon Syntax Highlighter v2.7.1 -->

		<div id="crayon-55ebd96717bac765992797" class="crayon-syntax crayon-theme-bncplusplus crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
		
			<div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><span class="crayon-title"></span>
			<div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><div class="crayon-button crayon-nums-button" title="Toggle Line Numbers"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-plain-button" title="Toggle Plain Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-wrap-button" title="Toggle Line Wrap"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-expand-button" title="Expand Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-copy-button" title="Copy"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-popup-button" title="Open Code In New Window"><div class="crayon-button-icon"></div></div></div></div>
			<div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;"></div>
			<div class="crayon-plain-wrap"><textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">
PHP_MINIT_FUNCTION(vehicles)
{
    zend_class_entry ce;
    INIT_CLASS_ENTRY(ce, "Car", car_methods);
    car_ce = zend_register_internal_class(&amp;ce TSRMLS_CC);
    car_ce-&gt;create_object = car_create_handler;
    memcpy(&amp;car_object_handlers,
        zend_get_std_object_handlers(), sizeof(zend_object_handlers));
    car_object_handlers.clone_obj = NULL;
    return SUCCESS;
}</textarea></div>
			<div class="crayon-main" style="">
				<table class="crayon-table">
					<tr class="crayon-row">
				<td class="crayon-nums " data-settings="show">
					<div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"><div class="crayon-num" data-line="crayon-55ebd96717bac765992797-1">1</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bac765992797-2">2</div><div class="crayon-num" data-line="crayon-55ebd96717bac765992797-3">3</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bac765992797-4">4</div><div class="crayon-num" data-line="crayon-55ebd96717bac765992797-5">5</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bac765992797-6">6</div><div class="crayon-num" data-line="crayon-55ebd96717bac765992797-7">7</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bac765992797-8">8</div><div class="crayon-num" data-line="crayon-55ebd96717bac765992797-9">9</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bac765992797-10">10</div><div class="crayon-num" data-line="crayon-55ebd96717bac765992797-11">11</div></div>
				</td>
						<td class="crayon-code"><div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><div class="crayon-line" id="crayon-55ebd96717bac765992797-1"><span class="crayon-e">PHP_MINIT_FUNCTION</span><span class="crayon-sy">(</span><span class="crayon-v">vehicles</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bac765992797-2"><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717bac765992797-3"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">zend_class_entry </span><span class="crayon-v">ce</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bac765992797-4"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">INIT_CLASS_ENTRY</span><span class="crayon-sy">(</span><span class="crayon-v">ce</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-s">"Car"</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">car_methods</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717bac765992797-5"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">car_ce</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-e">zend_register_internal_class</span><span class="crayon-sy">(</span><span class="crayon-o">&amp;</span><span class="crayon-e">ce </span><span class="crayon-v">TSRMLS_CC</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bac765992797-6"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">car_ce</span><span class="crayon-o">-&gt;</span><span class="crayon-v">create_object</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-v">car_create_handler</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717bac765992797-7"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">memcpy</span><span class="crayon-sy">(</span><span class="crayon-o">&amp;</span><span class="crayon-v">car_object_handlers</span><span class="crayon-sy">,</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bac765992797-8"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">zend_get_std_object_handlers</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-e">sizeof</span><span class="crayon-sy">(</span><span class="crayon-v">zend_object_handlers</span><span class="crayon-sy">)</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717bac765992797-9"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">car_object_handlers</span><span class="crayon-sy">.</span><span class="crayon-v">clone_obj</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-t">NULL</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bac765992797-10"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-st">return</span><span class="crayon-h"> </span><span class="crayon-v">SUCCESS</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717bac765992797-11"><span class="crayon-sy">}</span></div></div></td>
					</tr>
				</table>
			</div>
		</div>
<!-- [Format Time: 0.0016 seconds] -->
<p></p>
<p>There’s quite a bit going on here. First, once we have a dedicated zend_class_entry pointer in the MINIT_FUNCTION, we can assign a create_object handler to it. The create_object handler allocates memory for the object, sets up the zend_object and generates a handle for the object by storing the car_object pointer. You’ll also notice that the zend_objects_store_put function accepts a function pointer to what is basically a c-level destructor for the object being handled.</p>
<p>Finally, in your PHP class constructor, you’ll parse the user parameters like usual and pass them on to the C++ constructor. Once the C++ class instance is created, you can fetch the car_object pointer from the zend object store and set the car field in the struct. This makes the C++ class instance available to other instance methods of your PHP class.</p>
<p></p><!-- Crayon Syntax Highlighter v2.7.1 -->

		<div id="crayon-55ebd96717bb1102137916" class="crayon-syntax crayon-theme-bncplusplus crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
		
			<div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><span class="crayon-title"></span>
			<div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><div class="crayon-button crayon-nums-button" title="Toggle Line Numbers"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-plain-button" title="Toggle Plain Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-wrap-button" title="Toggle Line Wrap"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-expand-button" title="Expand Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-copy-button" title="Copy"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-popup-button" title="Open Code In New Window"><div class="crayon-button-icon"></div></div></div></div>
			<div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;"></div>
			<div class="crayon-plain-wrap"><textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">
PHP_METHOD(Car, __construct)
{
    long maxGear;
    Car *car = NULL;
    zval *object = getThis();

    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &amp;maxGear) == FAILURE) {
        RETURN_NULL();
    }

    car = new Car(maxGear);
    car_object *obj = (car_object *)zend_object_store_get_object(object TSRMLS_CC);
    obj-&gt;car = car;
}</textarea></div>
			<div class="crayon-main" style="">
				<table class="crayon-table">
					<tr class="crayon-row">
				<td class="crayon-nums " data-settings="show">
					<div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"><div class="crayon-num" data-line="crayon-55ebd96717bb1102137916-1">1</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb1102137916-2">2</div><div class="crayon-num" data-line="crayon-55ebd96717bb1102137916-3">3</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb1102137916-4">4</div><div class="crayon-num" data-line="crayon-55ebd96717bb1102137916-5">5</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb1102137916-6">6</div><div class="crayon-num" data-line="crayon-55ebd96717bb1102137916-7">7</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb1102137916-8">8</div><div class="crayon-num" data-line="crayon-55ebd96717bb1102137916-9">9</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb1102137916-10">10</div><div class="crayon-num" data-line="crayon-55ebd96717bb1102137916-11">11</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb1102137916-12">12</div><div class="crayon-num" data-line="crayon-55ebd96717bb1102137916-13">13</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb1102137916-14">14</div></div>
				</td>
						<td class="crayon-code"><div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><div class="crayon-line" id="crayon-55ebd96717bb1102137916-1"><span class="crayon-e">PHP_METHOD</span><span class="crayon-sy">(</span><span class="crayon-v">Car</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">__construct</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb1102137916-2"><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717bb1102137916-3"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-t">long</span><span class="crayon-h"> </span><span class="crayon-v">maxGear</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb1102137916-4"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e ">Car *</span><span class="crayon-v">car</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-t">NULL</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717bb1102137916-5"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e ">zval *</span><span class="crayon-t">object</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-e">getThis</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb1102137916-6">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717bb1102137916-7"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-st">if</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-e">zend_parse_parameters</span><span class="crayon-sy">(</span><span class="crayon-e">ZEND_NUM_ARGS</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-v">TSRMLS_CC</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-s">"l"</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-o">&amp;</span><span class="crayon-v">maxGear</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-o">==</span><span class="crayon-h"> </span><span class="crayon-v">FAILURE</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb1102137916-8"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">RETURN_NULL</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717bb1102137916-9"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-sy">}</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb1102137916-10">&nbsp;</div><div class="crayon-line" id="crayon-55ebd96717bb1102137916-11"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">car</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-r">new</span><span class="crayon-h"> </span><span class="crayon-e">Car</span><span class="crayon-sy">(</span><span class="crayon-v">maxGear</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb1102137916-12"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e ">car_object *</span><span class="crayon-v">obj</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-e ">car_object *</span><span class="crayon-sy">)</span><span class="crayon-e">zend_object_store_get_object</span><span class="crayon-sy">(</span><span class="crayon-t">object</span><span class="crayon-h"> </span><span class="crayon-v">TSRMLS_CC</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717bb1102137916-13"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">obj</span><span class="crayon-o">-&gt;</span><span class="crayon-v">car</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-v">car</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb1102137916-14"><span class="crayon-sy">}</span></div></div></td>
					</tr>
				</table>
			</div>
		</div>
<!-- [Format Time: 0.0020 seconds] -->
<p></p>
<p>Now, in order to obtain an instance of the C++ class, instance methods of your PHP class just need to call zend_object_store_get_object:</p>
<p></p><!-- Crayon Syntax Highlighter v2.7.1 -->

		<div id="crayon-55ebd96717bb5717802352" class="crayon-syntax crayon-theme-bncplusplus crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
		
			<div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><span class="crayon-title"></span>
			<div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><div class="crayon-button crayon-nums-button" title="Toggle Line Numbers"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-plain-button" title="Toggle Plain Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-wrap-button" title="Toggle Line Wrap"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-expand-button" title="Expand Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-copy-button" title="Copy"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-popup-button" title="Open Code In New Window"><div class="crayon-button-icon"></div></div></div></div>
			<div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;"></div>
			<div class="crayon-plain-wrap"><textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">
PHP_METHOD(accelerate)
{
    Car *car;
    car_object *obj = (car_object *)zend_object_store_get_object(
        getThis() TSRMLS_CC);
    car = obj-&gt;car;
    if (car != NULL) {
        car-&gt;accelerate();
    }
}

PHP_METHOD(getCurrentSpeed)
{
    Car *car;
    car_object *obj = (car_object *)zend_object_store_get_object(
        getThis() TSRMLS_CC);
    car = obj-&gt;car;
    if (car != NULL) {
        RETURN_LONG(car-&gt;getCurrentSpeed());
    }
    RETURN_NULL();
}</textarea></div>
			<div class="crayon-main" style="">
				<table class="crayon-table">
					<tr class="crayon-row">
				<td class="crayon-nums " data-settings="show">
					<div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"><div class="crayon-num" data-line="crayon-55ebd96717bb5717802352-1">1</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb5717802352-2">2</div><div class="crayon-num" data-line="crayon-55ebd96717bb5717802352-3">3</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb5717802352-4">4</div><div class="crayon-num" data-line="crayon-55ebd96717bb5717802352-5">5</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb5717802352-6">6</div><div class="crayon-num" data-line="crayon-55ebd96717bb5717802352-7">7</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb5717802352-8">8</div><div class="crayon-num" data-line="crayon-55ebd96717bb5717802352-9">9</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb5717802352-10">10</div><div class="crayon-num" data-line="crayon-55ebd96717bb5717802352-11">11</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb5717802352-12">12</div><div class="crayon-num" data-line="crayon-55ebd96717bb5717802352-13">13</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb5717802352-14">14</div><div class="crayon-num" data-line="crayon-55ebd96717bb5717802352-15">15</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb5717802352-16">16</div><div class="crayon-num" data-line="crayon-55ebd96717bb5717802352-17">17</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb5717802352-18">18</div><div class="crayon-num" data-line="crayon-55ebd96717bb5717802352-19">19</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb5717802352-20">20</div><div class="crayon-num" data-line="crayon-55ebd96717bb5717802352-21">21</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb5717802352-22">22</div></div>
				</td>
						<td class="crayon-code"><div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><div class="crayon-line" id="crayon-55ebd96717bb5717802352-1"><span class="crayon-e">PHP_METHOD</span><span class="crayon-sy">(</span><span class="crayon-v">accelerate</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb5717802352-2"><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717bb5717802352-3"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e ">Car *</span><span class="crayon-v">car</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb5717802352-4"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e ">car_object *</span><span class="crayon-v">obj</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-e ">car_object *</span><span class="crayon-sy">)</span><span class="crayon-e">zend_object_store_get_object</span><span class="crayon-sy">(</span></div><div class="crayon-line" id="crayon-55ebd96717bb5717802352-5"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">getThis</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-v">TSRMLS_CC</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb5717802352-6"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">car</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-v">obj</span><span class="crayon-o">-&gt;</span><span class="crayon-v">car</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717bb5717802352-7"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-st">if</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-v">car</span><span class="crayon-h"> </span><span class="crayon-o">!=</span><span class="crayon-h"> </span><span class="crayon-t">NULL</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb5717802352-8"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">car</span><span class="crayon-o">-&gt;</span><span class="crayon-e">accelerate</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717bb5717802352-9"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-sy">}</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb5717802352-10"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-55ebd96717bb5717802352-11">&nbsp;</div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb5717802352-12"><span class="crayon-e">PHP_METHOD</span><span class="crayon-sy">(</span><span class="crayon-v">getCurrentSpeed</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-55ebd96717bb5717802352-13"><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb5717802352-14"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e ">Car *</span><span class="crayon-v">car</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717bb5717802352-15"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e ">car_object *</span><span class="crayon-v">obj</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-e ">car_object *</span><span class="crayon-sy">)</span><span class="crayon-e">zend_object_store_get_object</span><span class="crayon-sy">(</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb5717802352-16"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">getThis</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-v">TSRMLS_CC</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717bb5717802352-17"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">car</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-v">obj</span><span class="crayon-o">-&gt;</span><span class="crayon-v">car</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb5717802352-18"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-st">if</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-v">car</span><span class="crayon-h"> </span><span class="crayon-o">!=</span><span class="crayon-h"> </span><span class="crayon-t">NULL</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-55ebd96717bb5717802352-19"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">RETURN_LONG</span><span class="crayon-sy">(</span><span class="crayon-v">car</span><span class="crayon-o">-&gt;</span><span class="crayon-e">getCurrentSpeed</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb5717802352-20"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-55ebd96717bb5717802352-21"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-e">RETURN_NULL</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb5717802352-22"><span class="crayon-sy">}</span></div></div></td>
					</tr>
				</table>
			</div>
		</div>
<!-- [Format Time: 0.0026 seconds] -->
<p></p>
<p>The remaining methods all work in basically the same way, I’ll leave implementing them as an exercise.</p>
<p>That’s it, we’re done! Now let’s take our new extension for a test drive. Don’t forget to re-compile, install and of course enable it in php.ini (or continue to use the -dextension=vehicles.so command line argument).</p>
<p></p><!-- Crayon Syntax Highlighter v2.7.1 -->

		<div id="crayon-55ebd96717bb9640174447" class="crayon-syntax crayon-theme-bncplusplus crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
		
			<div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><span class="crayon-title"></span>
			<div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><div class="crayon-button crayon-nums-button" title="Toggle Line Numbers"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-plain-button" title="Toggle Plain Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-wrap-button" title="Toggle Line Wrap"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-expand-button" title="Expand Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-copy-button" title="Copy"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-popup-button" title="Open Code In New Window"><div class="crayon-button-icon"></div></div></div></div>
			<div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;"></div>
			<div class="crayon-plain-wrap"><textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">
// create a 5 gear car
$car = new Car(5);
print $car-&gt;getCurrentSpeed();  // prints '0'
$car-&gt;accelerate();
print $car-&gt;getCurrentSpeed(); // prints '5'</textarea></div>
			<div class="crayon-main" style="">
				<table class="crayon-table">
					<tr class="crayon-row">
				<td class="crayon-nums " data-settings="show">
					<div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"><div class="crayon-num" data-line="crayon-55ebd96717bb9640174447-1">1</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb9640174447-2">2</div><div class="crayon-num" data-line="crayon-55ebd96717bb9640174447-3">3</div><div class="crayon-num crayon-striped-num" data-line="crayon-55ebd96717bb9640174447-4">4</div><div class="crayon-num" data-line="crayon-55ebd96717bb9640174447-5">5</div></div>
				</td>
						<td class="crayon-code"><div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><div class="crayon-line" id="crayon-55ebd96717bb9640174447-1"><span class="crayon-c">// create a 5 gear car</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb9640174447-2"><span class="crayon-sy">$</span><span class="crayon-v">car</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-r">new</span><span class="crayon-h"> </span><span class="crayon-e">Car</span><span class="crayon-sy">(</span><span class="crayon-cn">5</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717bb9640174447-3"><span class="crayon-i">print</span><span class="crayon-h"> </span><span class="crayon-sy">$</span><span class="crayon-v">car</span><span class="crayon-o">-&gt;</span><span class="crayon-e">getCurrentSpeed</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span><span class="crayon-h">&nbsp;&nbsp;</span><span class="crayon-c">// prints '0'</span></div><div class="crayon-line crayon-striped-line" id="crayon-55ebd96717bb9640174447-4"><span class="crayon-sy">$</span><span class="crayon-v">car</span><span class="crayon-o">-&gt;</span><span class="crayon-e">accelerate</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-55ebd96717bb9640174447-5"><span class="crayon-i">print</span><span class="crayon-h"> </span><span class="crayon-sy">$</span><span class="crayon-v">car</span><span class="crayon-o">-&gt;</span><span class="crayon-e">getCurrentSpeed</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span><span class="crayon-h"> </span><span class="crayon-c">// prints '5'</span></div></div></td>
					</tr>
				</table>
			</div>
		</div>
<!-- [Format Time: 0.0009 seconds] -->
<p></p>
<p>If you can run this script, congratulations, you’ve just created a PHP extension that wraps a C++ class.</p>
<!-- Social Buttons Generated by Digg Digg plugin v5.3.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->							</div><!-- .entry-content -->
			
		
		<footer class="entry-meta">
			<!-- Post end widget area -->
							<div class="post-end-widget-area">
									</div>
						
						<div class="entry-meta-term">
			<span class="term-icon"><i class="fa fa-folder-open"></i></span> <a href="http://devzone.zend.com/category/tutorials/" rel="tag">Tutorials</a>			
						
			<div style="float:right;"></div>
			</div>
			
						
					</footer><!-- .entry-meta -->
	</article><!-- #post -->

				<nav class="nav-single">
					<h3 class="assistive-text">Post navigation</h3>
					<div class="wrapper-navigation-below">
					<span class="nav-previous"><a href="http://devzone.zend.com/1434/mysql-announcements_oracle-mysql-54/" rel="prev"><span class="meta-nav">&larr;</span> MySQL announcements:  Oracle &#038; MySQL 5.4</a></span>
					<span class="nav-next"><a href="http://devzone.zend.com/1436/the-zendcon-sessions-episode-17-sql-query-tuning-the-legend-of-drunken-query-master/" rel="next">The ZendCon Sessions Episode 17: SQL Query Tuning: The Legend of Drunken Query Master <span class="meta-nav">&rarr;</span></a></span>
					</div><!-- .wrapper-navigation-below -->
				</nav><!-- .nav-single -->

				<div id="social">
		<div class="social-post">
		<div id="loading" style="display:none">
			<input type="hidden" id="reload_url" value="http://devzone.zend.com/index.php?social_controller=auth&#038;social_action=reload_form&#038;redirect_to=http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/&#038;post_id=1435" />
			Logging In...		</div>
				<p class="nocomments">Comments are closed.</p>
			</div>
	<div id="social-tabs-comments">
				<ul class="social-nav social-clearfix">
			<li class="social-all social-tab-main social-current-tab"><a href="#" rel="social-all"><span>33 Replies</span></a></li>
			<li class="social-wordpress"><a href="#" rel="wordpress"><span>33 Comments</span></a></li>
			<li class="social-twitter"><a href="#" rel="social-twitter"><span>0 Tweets</span></a></li>
			<li class="social-facebook"><a href="#" rel="social-facebook"><span>0 Facebook</span></a></li>
			<li class="social-pingback"><a href="#" rel="social-pingback"><span>0 Pingbacks</span></a></li>
		</ul>

		<!-- panel items -->
		<div id="social-comments-tab-all" class="social-tabs-panel social-tabs-first-panel">
			<div id="comments" class="social-comments">
				<div class="social-last-reply-when">Last reply was October 17, 2011</div><div class="cf-clearfix"></div>				<ol class="social-commentlist">
				<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-35">
<div class="social-comment-inner social-clearfix" id="comment-35">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://2.gravatar.com/avatar/8bb8c904730537e3abfd96b104a3fded?s=40&#038;d=mm&#038;r=g' srcset='http://2.gravatar.com/avatar/8bb8c904730537e3abfd96b104a3fded?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">akki_nitsch</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-35" class="social-posted-when" target="_blank">October 17, 2011</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>Hi everybody,</p>
<p>first of all i&#8217;ve got to thank paulosman for this tutorial &#8211; great job <img src="http://devzone.zend.com/wp-includes/images/smilies/simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>I was able to reproduce the tutorial on a virtual machine under Linux on a i386 processor &#8211; everything worked perfectly fine.<br />
After that i tried to cross-compile php and the PHP extension for a board with an ARM processor (in this case an ARM926EJ-S).<br />
Cross-compiling of PHP and the extension worked but sadly the installation on the board failed.</p>
<p>When i call &quot;php -m&quot; on the console, the extension is not listed (i already enabled the extension in php.ini).<br />
The attempt to load the extension dynamically via console with &quot;php -d&quot;extensions=vehicles.so&quot; -m&quot; does not produce any<br />
warning or error &#8211; but the extention is not loaded.</p>
<p>Loading the module with &quot;dl(vehicles.so)&quot; in a php script produces the following warning:<br />
&quot;Warning: dl(): Cannot dynamically load vehicles.so &#8211; dynamic modules are not supported in /usr/local/lib/php/extensions/no-debug-non-zts-20090626/test.php on line 12&quot;</p>
<p>Has anyone experiences with cross-compiling of self-written PHP-extensions. I would be very glad for any hint.</p>
<p>Best regards</p>
<p>Andreas</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-35 -->
</li><!-- #comment-## -->
<li class="wordpress odd alt thread-odd thread-alt depth-1 social-comment social-clearfix social-wordpress" id="li-comment-63">
<div class="social-comment-inner social-clearfix" id="comment-63">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://1.gravatar.com/avatar/4f8bb641e2604fecb47224c30b0990b5?s=40&#038;d=mm&#038;r=g' srcset='http://1.gravatar.com/avatar/4f8bb641e2604fecb47224c30b0990b5?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">fan_me</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-63" class="social-posted-when" target="_blank">September 12, 2011</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>Hi,</p>
<p>I have the following .h:<br />
public:<br />
class First<br />
{<br />
First();<br />
public;<br />
class Second<br />
{<br />
Second();<br />
class Data<br />
{<br />
//methods, variables<br />
};<br />
bool methodd(First::Second &amp;obj);<br />
};<br />
};</p>
<p>how to rewrite your vehicles.cc in this case? how to create a method that waits for a reference? how to link to classes and nested classes?</p>
<p>YHX . APPRECIATE</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-63 -->
</li><!-- #comment-## -->
<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-170">
<div class="social-comment-inner social-clearfix" id="comment-170">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://1.gravatar.com/avatar/129e0e9fa4a322bb5ace8495a89c97ec?s=40&#038;d=mm&#038;r=g' srcset='http://1.gravatar.com/avatar/129e0e9fa4a322bb5ace8495a89c97ec?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">nina_din</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-170" class="social-posted-when" target="_blank">May 25, 2011</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>Hi,<br />
Thank you for your helpful sample.<br />
I have to develop an extension with 2 class. the first class , its name is Point- gets int x , int y as constructor parameter.also it has 3 methods, getx(), getY() and getXY() functions. this works well. <br />
The second extension  is another class that constructor&#8217;s parameters are Point class type. for example SecClass ( new Point (2,3));<br />
the implementation in c++ is correct and it works. but when i test it as extension, it does not return correct value.can u help me what should I do?<br />
I can send my classes to you.</p>
<p>I really appreciate.</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-170 -->
</li><!-- #comment-## -->
<li class="wordpress odd alt thread-odd thread-alt depth-1 social-comment social-clearfix social-wordpress" id="li-comment-329">
<div class="social-comment-inner social-clearfix" id="comment-329">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://2.gravatar.com/avatar/53d1a2614d23c607e64edb793021d124?s=40&#038;d=mm&#038;r=g' srcset='http://2.gravatar.com/avatar/53d1a2614d23c607e64edb793021d124?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">miracletan</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-329" class="social-posted-when" target="_blank">December 16, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>Hi:<br />
I follow these steps, but i got a problem below:<br />
-bash-3.2# php -m<br />
PHP Warning:  PHP Startup: Unable to load dynamic library &#8216;/usr/lib64/php/modules/vehicles.so&#8217; &#8211; /usr/lib64/php/modules/vehicles.so: undefined symbol: _ZN3CarC1Ei in Unknown on line 0</p>
<p>I tried a lot,but it still doesn&#8217;t work&#8230; <img src="http://devzone.zend.com/wp-includes/images/smilies/frownie.png" alt=":(" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>PS:I changed &quot;CC=gcc&quot; to &quot;CC=g++&quot; in Makefile.</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-329 -->
</li><!-- #comment-## -->
<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-330">
<div class="social-comment-inner social-clearfix" id="comment-330">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://2.gravatar.com/avatar/53d1a2614d23c607e64edb793021d124?s=40&#038;d=mm&#038;r=g' srcset='http://2.gravatar.com/avatar/53d1a2614d23c607e64edb793021d124?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">miracletan</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-330" class="social-posted-when" target="_blank">December 16, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>Hi:<br />
I follow these steps, but i got a problem below:<br />
-bash-3.2# php -m<br />
PHP Warning:  PHP Startup: Unable to load dynamic library &#8216;/usr/lib64/php/modules/vehicles.so&#8217; &#8211; /usr/lib64/php/modules/vehicles.so: undefined symbol: _ZN3CarC1Ei in Unknown on line 0</p>
<p>I tried a lot,but it still doesn&#8217;t work&#8230; <img src="http://devzone.zend.com/wp-includes/images/smilies/frownie.png" alt=":(" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>PS:I changed &quot;CC=gcc&quot; to &quot;CC=g++&quot; in Makefile.</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-330 -->
</li><!-- #comment-## -->
<li class="wordpress odd alt thread-odd thread-alt depth-1 social-comment social-clearfix social-wordpress" id="li-comment-378">
<div class="social-comment-inner social-clearfix" id="comment-378">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://1.gravatar.com/avatar/1a710a995dc3b4f656ee98f7539208c0?s=40&#038;d=mm&#038;r=g' srcset='http://1.gravatar.com/avatar/1a710a995dc3b4f656ee98f7539208c0?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn"><a href='http://www.contentwithstyle.co.uk' rel='external nofollow' class='url'>contentwithstyle</a></cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-378" class="social-posted-when" target="_blank">November 6, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>One thing I didn&#8217;t see mentioned here is any potential speed benefit. I don&#8217;t know if there is one for PHP, but in the world of Perl there is the concept of XSification (<a href="http://perldoc.perl.org/perlxs.html" rel="nofollow">http://perldoc.perl.org/perlxs.html</a>), effectively writing Perl classes in C, which has in many cases a massive speed improvement.</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-378 -->
</li><!-- #comment-## -->
<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-453">
<div class="social-comment-inner social-clearfix" id="comment-453">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/6611b6cc57ae368eb778cca8dc626a0c?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/6611b6cc57ae368eb778cca8dc626a0c?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">a_white</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-453" class="social-posted-when" target="_blank">September 29, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>struct car_object {<br />
    zend_object std;<br />
    Car *car;<br />
};</p>
<p>Don&#8217;t understand why we must add a zend_object member in car_object. Check out zend_objects_store_put function and zend_object_store_get_object function in zend source code(zend_objects_API.c),they don&#8217;t use the &quot;zend_object std&quot; in car_object,so i don&#8217;t what it is for?</p>
<p>Could you explain why we must put one zend_object into first place in object struct ?<br />
Thanks.</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-453 -->
</li><!-- #comment-## -->
<li class="wordpress odd alt thread-odd thread-alt depth-1 social-comment social-clearfix social-wordpress" id="li-comment-658">
<div class="social-comment-inner social-clearfix" id="comment-658">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/9fa1e50a1ecb05573ae9f57dd0e990dd?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/9fa1e50a1ecb05573ae9f57dd0e990dd?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">thebigonion</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-658" class="social-posted-when" target="_blank">May 18, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>Grrrrr.</p>
<p> If I do this:<br />
 &#8212;&#8212;&#8212;&#8212;-<br />
 string myString1;<br />
 int myInt;<br />
 string myString2;</p>
<p> if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, &quot;sls&quot;, &amp;myString1, &amp;myInt, &amp;myString2) == FAILURE)<br />
 {<br />
   RETURN_NULL();<br />
  }<br />
 &#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p> And then run it, I get a &quot;Segmentation Fault (core dumped)&quot; error.</p>
<p> But if I add in the extra ints for my strings like:<br />
 &#8212;&#8212;&#8212;&#8212;&#8212;-<br />
 string myString1;<br />
 int myInt;<br />
 string myString2;<br />
 int myStringInt1, myStringInt2;</p>
<p> if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, &quot;sls&quot;, &amp;myString1, &amp;myStringInt1, &amp;myInt, &amp;myString2, &amp;myStringInt2) == FAILURE)<br />
 {<br />
   RETURN_NULL();<br />
  }<br />
 &#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p> when I run it I get a bunch of text.  Here&#8217;s part:<br />
 &#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
 Start: Overflown (magic=0x345ACE99F instead of 0x0A9CEA43)<br />
        1 byte(s) overflown<br />
 End:   OK<br />
&#8230;<br />
  === Total 2 memory leaks detected ===<br />
 &#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>
 Can someone please help me figure out what I am doing wrong?</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-658 -->
</li><!-- #comment-## -->
<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-660">
<div class="social-comment-inner social-clearfix" id="comment-660">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/0ee9fef46521820e2a08f79397f36cbd?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/0ee9fef46521820e2a08f79397f36cbd?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">scaupp</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-660" class="social-posted-when" target="_blank">May 17, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>I&#8217;ve never tried using std::string, so I don&#8217;t know if that will parse correctly, you may have to use a pointer to a char array.</p>
<p>If you&#8217;re asking if you have to initialize the string length vars, then no, you don&#8217;t, the zend_parse_parameters call fills that in with the length of the string passed in.</p>
<p>I&#8217;m 99% certain that you can&#8217;t just pass the values by reference and have PHP see the results, but I&#8217;m no expert on this, I just happen to have gotten our extension to finally work&#8230; <img src="http://devzone.zend.com/wp-includes/images/smilies/simple-smile.png" alt=":-)" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-660 -->
</li><!-- #comment-## -->
<li class="wordpress odd alt thread-odd thread-alt depth-1 social-comment social-clearfix social-wordpress" id="li-comment-661">
<div class="social-comment-inner social-clearfix" id="comment-661">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/9fa1e50a1ecb05573ae9f57dd0e990dd?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/9fa1e50a1ecb05573ae9f57dd0e990dd?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">thebigonion</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-661" class="social-posted-when" target="_blank">May 17, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>And do I need to set any values to the string lengths?</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-661 -->
</li><!-- #comment-## -->
<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-662">
<div class="social-comment-inner social-clearfix" id="comment-662">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/9fa1e50a1ecb05573ae9f57dd0e990dd?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/9fa1e50a1ecb05573ae9f57dd0e990dd?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">thebigonion</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-662" class="social-posted-when" target="_blank">May 17, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>Thank you so much.  You have been a great help.<br />
One more question:</p>
<p>Does this look right?</p>
<p>std::string ab_IDCode1;<br />
int iabCode1Len;<br />
int is_by;<br />
std::string ab_IDCode3;<br />
std::string ab_IDCode2;<br />
int iabCode2Len, iabCode3Len;</p>
<p>if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,<br />
&quot;slss&quot;,<br />
&amp;ab_IDCode1, &amp;iabCode1Len, &amp;is_by,<br />
&amp;ab_IDCode2, &amp;iabCode2Len,<br />
&amp;ab_IDCode3, &amp;iabCode3Len,) == FAILURE) {<br />
RETURN_NULL();<br />
}</p>
<p>Also, my &amp;iabCode3 is a parameter that is sent via reference and so my call in PHP should be able to see the value in that variable after the call to the method.</p>
<p>Thanks again.</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-662 -->
</li><!-- #comment-## -->
<li class="wordpress odd alt thread-odd thread-alt depth-1 social-comment social-clearfix social-wordpress" id="li-comment-666">
<div class="social-comment-inner social-clearfix" id="comment-666">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/0ee9fef46521820e2a08f79397f36cbd?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/0ee9fef46521820e2a08f79397f36cbd?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">scaupp</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-666" class="social-posted-when" target="_blank">May 13, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>The &#8216;ssll&#8217; indicates two strings and two integers.  The six variables hold the first string, the length of the first string, the second string, the length of the second string, the first integer, and the second integer.  I.e. for every string param you pass in you have to parse it out to two variables, one for the string and one for the length.</p>
<p>Extending and Embedding PHP (the author is a woman, BTW) has a few holes that make it a little tricky if you&#8217;re not already familiar with how the PHP stuff is coded in C.</p>
<p>Code like the above should work, I checked it against our working extension DLL.</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-666 -->
</li><!-- #comment-## -->
<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-667">
<div class="social-comment-inner social-clearfix" id="comment-667">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/9fa1e50a1ecb05573ae9f57dd0e990dd?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/9fa1e50a1ecb05573ae9f57dd0e990dd?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">thebigonion</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-667" class="social-posted-when" target="_blank">May 13, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>It&#8217;s weird,<br />
 if you look in &quot;Extending and Embedding PHP&quot; on page 82, the example is like yours, but has 2 strings and 2 integers.  But in his zend_parse_parameters he only declares &quot;ss&quot;.  What about the integers?</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-667 -->
</li><!-- #comment-## -->
<li class="wordpress odd alt thread-odd thread-alt depth-1 social-comment social-clearfix social-wordpress" id="li-comment-668">
<div class="social-comment-inner social-clearfix" id="comment-668">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/0ee9fef46521820e2a08f79397f36cbd?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/0ee9fef46521820e2a08f79397f36cbd?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">scaupp</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-668" class="social-posted-when" target="_blank">May 13, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>It&#8217;s been a while, but something like this, I believe:</p>
<p>    unsigned char *ab_IDCode1, *ab_IDCode2;<br />
    int iabCode1Len, iabCode2Len;<br />
    int is_by, iDays;</p>
<p>    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,<br />
                              &quot;ssll&quot;,<br />
                              &amp;ab_IDCode1, &amp;iabCode1Len,<br />
                              &amp;ab_IDCode2, &amp;iabCode2Len,<br />
                              &amp;is_by, &amp;iDays) == FAILURE) {<br />
        RETURN_NULL();<br />
    }</p>
<p>HTH</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-668 -->
</li><!-- #comment-## -->
<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-669">
<div class="social-comment-inner social-clearfix" id="comment-669">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/9fa1e50a1ecb05573ae9f57dd0e990dd?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/9fa1e50a1ecb05573ae9f57dd0e990dd?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">thebigonion</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-669" class="social-posted-when" target="_blank">May 13, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>ok, so I see how to do it with:</p>
<p>if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, &quot;l&quot;, &amp;maxGear) == FAILURE) <br />
{<br />
        RETURN_NULL();<br />
}</p>
<p>But, how do I pass in a string and an integer?  The examples in &quot;Extending and Embedding PHP&quot; don&#8217;t show two different argument types.</p>
<p>Thanks</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-669 -->
</li><!-- #comment-## -->
<li class="wordpress odd alt thread-odd thread-alt depth-1 social-comment social-clearfix social-wordpress" id="li-comment-670">
<div class="social-comment-inner social-clearfix" id="comment-670">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/9fa1e50a1ecb05573ae9f57dd0e990dd?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/9fa1e50a1ecb05573ae9f57dd0e990dd?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">thebigonion</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-670" class="social-posted-when" target="_blank">May 12, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>What should this look like?:<br />
PHP_METHOD(Car, shift)<br />
{<br />
}</p>
<p>In my real code, I have a method that takes two arguments:<br />
function this(const std:string myString, const int myInt)<br />
but i do not know how to change my PHP_METHOD to handle it.</p>
<p>Can you please show me using the vehicle example? (shift takes an argument)</p>
<p>Thanks.</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-670 -->
</li><!-- #comment-## -->
<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-705">
<div class="social-comment-inner social-clearfix" id="comment-705">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://1.gravatar.com/avatar/4e48995bd268d999de0d02feff61f24f?s=40&#038;d=mm&#038;r=g' srcset='http://1.gravatar.com/avatar/4e48995bd268d999de0d02feff61f24f?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">davidweaverking</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-705" class="social-posted-when" target="_blank">April 21, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>No, but your comment did help.  Apparently when you specify libraries for ld to link it (like what eventually happens in this process) ld looks for a library called &quot;lib&lt;libraryName&gt;.so&quot;.  In my previous tries that meant that ld was looking for a library called liblibvirt.so and (obviously) not finding it.  So&#8230;what finally worked was </p>
<p>PHP_ADD_LIBRARY(virt, 1, PHPVIRT_SHARED_LIBADD)</p>
<p>I hope this helps some else as well.  It took me a day and a half to solve it <img src="http://devzone.zend.com/wp-includes/images/smilies/simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-705 -->
</li><!-- #comment-## -->
<li class="wordpress odd alt thread-odd thread-alt depth-1 social-comment social-clearfix social-wordpress" id="li-comment-706">
<div class="social-comment-inner social-clearfix" id="comment-706">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/f6f231e50b27dd0d5755ecdff3cd571f?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/f6f231e50b27dd0d5755ecdff3cd571f?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">dabaipang</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-706" class="social-posted-when" target="_blank">April 21, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>did you try:<br />
make LDFLAGS=&quot;-lvirt&quot;</p>
<p>or did you put your .so file under liken/usr/local/php/lib<br />
which is a default path for your php to find it.</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-706 -->
</li><!-- #comment-## -->
<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-707">
<div class="social-comment-inner social-clearfix" id="comment-707">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://1.gravatar.com/avatar/4e48995bd268d999de0d02feff61f24f?s=40&#038;d=mm&#038;r=g' srcset='http://1.gravatar.com/avatar/4e48995bd268d999de0d02feff61f24f?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">davidweaverking</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-707" class="social-posted-when" target="_blank">April 21, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>Is there documentation anywhere (besides the source code) of the functions available in the config.m4 file (like the PHP_ADD_LIBRARY function)?  I&#8217;m trying to link against the shared library /usr/lib/libvirt.so  so I added the line </p>
<p>PHP_ADD_LIBRARY(libvirt, 1, PHPVIRT_SHARED_LIBADD)</p>
<p>to my config.m4 file but when I run make it gives the error</p>
<p>/usr/bin/ld: cannot find -llibvirt</p>
<p>I&#8217;ve tried using libvirt.so and PHP_ADD_LIBRARY_WITH_PATH but it always gives the same error.  Any ideas what I&#8217;m doing wrong?</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-707 -->
</li><!-- #comment-## -->
<li class="wordpress odd alt thread-odd thread-alt depth-1 social-comment social-clearfix social-wordpress" id="li-comment-708">
<div class="social-comment-inner social-clearfix" id="comment-708">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/f6f231e50b27dd0d5755ecdff3cd571f?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/f6f231e50b27dd0d5755ecdff3cd571f?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">dabaipang</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-708" class="social-posted-when" target="_blank">April 19, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>1.<br />
 dnl PHP_NEW_EXTENSION(vehicles, vehicles.c, $ext_shared)<br />
  PHP_SUBST(VEHICLES_SHARED_LIBADD)<br />
  PHP_ADD_LIBRARY_WITH_PATH(stdc++, &quot;&quot;, VEHICLES_SHARED_LIBADD)<br />
  PHP_REQUIRE_CXX()<br />
  PHP_NEW_EXTENSION(vehicles, vehicles.cpp, $ext_shared)</p>
<p>PHP_NEW_EXTENSTION(vehicles, vehicles.c, $ext_shared)<br />
                                |<br />
                                ^<br />
                             vehicles.cc</p>
<p>2. in vehicles.cc:<br />
Must:<br />
#ifdef COMPILE_DL_VEHICLES<br />
extern &quot;C&quot; {<br />
        ZEND_GET_MODULE(vehicles)<br />
}<br />
#endif</p>
<p>This is crucial, as it&#8217;s already pointed out by author.</p>
<p>3. in php_vehicles.h<br />
Must:<br />
extern &quot;C&quot; {<br />
#ifdef ZTS<br />
#include &quot;TSRM.h&quot;<br />
#endif<br />
}</p>
<p>It&#8217;s not mentioned in the post.</p>
<p>If you ever have ***.so maybe not a PHP library error, it means you have forgotten to extern &quot;C&quot; somewhere in either .h or .cpp/.cc files;</p>
<p>Everytime, make sure:<br />
phpize<br />
./configure &#8211;enable-vehicles<br />
make<br />
make install<br />
php vehicles.php</p>
<p>Thank you.</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-708 -->
</li><!-- #comment-## -->
<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-714">
<div class="social-comment-inner social-clearfix" id="comment-714">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/f6f231e50b27dd0d5755ecdff3cd571f?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/f6f231e50b27dd0d5755ecdff3cd571f?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">dabaipang</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-714" class="social-posted-when" target="_blank">April 18, 2010</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>I have followed exactly what you have written on the post, but at very first, vehicle.cc is something must be manually created.<br />
Did you deleted vehicle.c?</p>
<p>I tried deleting vehicle.c at first, but there is this error when I &#8216;make&#8217;<br />
make: *** No rule to make target <code>/home/qsl/download/php-5.3.1/ext/vehicles/vehicles.c', needed by </code>vehicles.lo&#8217;.  Stop.</p>
<p>Then I created a blank vehicles.c, somehow, it works, but when <br />
I use: $php -d&quot;extension=vehicles.so&quot; -m</p>
<p>There is this error:</p>
<p>PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) &#8216;vehicles.so&#8217; in Unknown on line 0</p>
<p>I can&#8217;t understand why there are so many people running through this without this problem.</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-714 -->
</li><!-- #comment-## -->
<li class="wordpress odd alt thread-odd thread-alt depth-1 social-comment social-clearfix social-wordpress" id="li-comment-957">
<div class="social-comment-inner social-clearfix" id="comment-957">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/0ee9fef46521820e2a08f79397f36cbd?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/0ee9fef46521820e2a08f79397f36cbd?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">scaupp</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-957" class="social-posted-when" target="_blank">November 16, 2009</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>With others, I&#8217;d like to thank you for posting this, it saved me quite some time.</p>
<p>And as others, I&#8217;ve got a question for you <img src="http://devzone.zend.com/wp-includes/images/smilies/simple-smile.png" alt=":-)" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>I adopted your approach versus the &quot;direct&quot; one in Sara Golemon&#8217;s &quot;Extending and Embedding PHP&quot; since we had an existing C++ object whose functionality we needed to integrate into our PHP scripts and didn&#8217;t want to muddy the original object with the PHP code as the C++ version is used separately in other applications.</p>
<p>One thing I have not been able to grok on my own is how to expose the properties in the underlying C++ object to PHP.  Do you have any hints on that that you could share?  I think the trick might be in implementing __set and __get functions and reading and setting the C++ object properties there, but I&#8217;m pretty much at sea at this point.</p>
<p>Thank you.</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-957 -->
</li><!-- #comment-## -->
<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-1005">
<div class="social-comment-inner social-clearfix" id="comment-1005">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://2.gravatar.com/avatar/57968375eaa236688940296fdc80428c?s=40&#038;d=mm&#038;r=g' srcset='http://2.gravatar.com/avatar/57968375eaa236688940296fdc80428c?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">nastikkl</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-1005" class="social-posted-when" target="_blank">October 21, 2009</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>Thank you for good article. Anyway I cant decide what to do in my situation.<br />
I have .dll file and .h file describing structure with pointers to library functions.<br />
I defined and registered that structure as a resource type in PHP, defined function which create and return the resource type. Still cant figure out how to work with function pointers in this case.</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-1005 -->
</li><!-- #comment-## -->
<li class="wordpress odd alt thread-odd thread-alt depth-1 social-comment social-clearfix social-wordpress" id="li-comment-1061">
<div class="social-comment-inner social-clearfix" id="comment-1061">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/339e4e5eda9a9acb8b560432338da1be?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/339e4e5eda9a9acb8b560432338da1be?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn"><a href='http://www.orfeuweb.ro' rel='external nofollow' class='url'>nicolae-serban</a></cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-1061" class="social-posted-when" target="_blank">September 18, 2009</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>Very good article, thank you </p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-1061 -->
</li><!-- #comment-## -->
<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-1190">
<div class="social-comment-inner social-clearfix" id="comment-1190">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://2.gravatar.com/avatar/8dbd64dffdf5dc23d7461386213b5e0d?s=40&#038;d=mm&#038;r=g' srcset='http://2.gravatar.com/avatar/8dbd64dffdf5dc23d7461386213b5e0d?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">niniwzw</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-1190" class="social-posted-when" target="_blank">August 12, 2009</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>i got the error:</p>
<p>Error 2 error LNK2019: unresolved external symbol __zval_ptr_dtor_wrapper, the symbol in function &quot;struct _zend_object_value __cdecl car_create_handler (struct _zend_class_entry *, void * * *)&quot; (? Car_create_handler @ @ YA? AU_zend_object_value @ @ PAU_zend_class_entry @ @ PAPAPAX @ Z) was quoted vehicles.obj </p>
<p>please help me , thanks.</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-1190 -->
</li><!-- #comment-## -->
<li class="wordpress odd alt thread-odd thread-alt depth-1 social-comment social-clearfix social-wordpress" id="li-comment-1351">
<div class="social-comment-inner social-clearfix" id="comment-1351">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/9b7d8c8b4f3039ecb9c36ab221302272?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/9b7d8c8b4f3039ecb9c36ab221302272?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">_____anonymous_____</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-1351" class="social-posted-when" target="_blank">June 10, 2009</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>I&#8217;ve got a statically linked library I&#8217;d like to make into a php module, it has a couple classes in it (but only one needed for interface). Anyway, I&#8217;d like the resulting php shared object module to have the entire library linked into it.  I have the sources for the library .c files compiled into a .o files, then combined into a library archive .a file. Is there a way to add .o files to a config.m4 file? or even better to just add a .a file to it directly?</p>
<p>thanks</p>
<p>P.S. the documentation for php module config macros on php.net is next to non-existant for php 5 =)</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-1351 -->
</li><!-- #comment-## -->
<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-1354">
<div class="social-comment-inner social-clearfix" id="comment-1354">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://1.gravatar.com/avatar/acb1bbe504fcfa67eaf7fdb9ee5f6170?s=40&#038;d=mm&#038;r=g' srcset='http://1.gravatar.com/avatar/acb1bbe504fcfa67eaf7fdb9ee5f6170?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">EABonney</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-1354" class="social-posted-when" target="_blank">June 9, 2009</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>Thanks for a great article! It has really gotten me started on the path I need for a project that I am working on. I was wondering though, is there a way to create an extension wrapper like this so that it is only exposed to the php project that needs it and not the entire server? I thought I read somewhere that it was possible to create such an extension but now I can&#8217;t figure out how.</p>
<p>I would like to create an extension and want it only available for my project and I don&#8217;t want my end users to have to install the .so file and then restart Apache etc..</p>
<p>Is this possible?</p>
<p>Thanks again!<br />
-Eric</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-1354 -->
</li><!-- #comment-## -->
<li class="wordpress odd alt thread-odd thread-alt depth-1 social-comment social-clearfix social-wordpress" id="li-comment-1360">
<div class="social-comment-inner social-clearfix" id="comment-1360">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://1.gravatar.com/avatar/11cf130976fa9b85904025ec872432d8?s=40&#038;d=mm&#038;r=g' srcset='http://1.gravatar.com/avatar/11cf130976fa9b85904025ec872432d8?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">paulosman</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-1360" class="social-posted-when" target="_blank">June 9, 2009</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>In order to be able to use a shared library from your extension code, you&#8217;ll need to modify your config.m4 file to link to it. To do this you can use the PHP_ADD_LIBRARY macro like we did in the tutorial in order to link to the libstdc++ library. If your shared library is installed somewhere non-standard (i.e. not in /lib, /usr/lib, etc) you can use the PHP_ADD_LIBRARY_WITH_PATH macro which accepts a path as an argument, i.e.: PHP_ADD_LIBRARY_WITH_PATH(external_lib, $EXTERNAL_LIB_DIR, VEHICLE_SHARED_LIBADD). Hope that helps! </p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-1360 -->
</li><!-- #comment-## -->
<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-1485">
<div class="social-comment-inner social-clearfix" id="comment-1485">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://1.gravatar.com/avatar/440dffc1b849556b57672b7b7cb93d1b?s=40&#038;d=mm&#038;r=g' srcset='http://1.gravatar.com/avatar/440dffc1b849556b57672b7b7cb93d1b?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">pdah87</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-1485" class="social-posted-when" target="_blank">May 3, 2009</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>This is really a great tutorial since you mentioned about linking the extension against an C/C++ library ( which has more reality than the other tutorials ). In your post, the library ( vehicle ) is built together with the extension. It&#8217;s a little different from my case : <br />
I had an existing shared library compiled and installed in my system, and I tried to build my extension to use the functions from that library ( without implementing it again in the extension source code ). <br />
But I can&#8217;t get my extension link to the library even the extension was compiled and installed correctly.<br />
I think the problem is somewhere around &quot;.configure&quot; or &quot;make&quot; command, but I didn&#8217;t find any solution yet. Can you suggest me a way to make it work?</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-1485 -->
</li><!-- #comment-## -->
<li class="wordpress odd alt thread-odd thread-alt depth-1 social-comment social-clearfix social-wordpress" id="li-comment-1487">
<div class="social-comment-inner social-clearfix" id="comment-1487">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/cc6f52842142cd96a5ab84779e502ee5?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/cc6f52842142cd96a5ab84779e502ee5?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">sherman81</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-1487" class="social-posted-when" target="_blank">May 2, 2009</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>i&#8217;ve compiled source code from your link and its working fine.</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-1487 -->
</li><!-- #comment-## -->
<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-1518">
<div class="social-comment-inner social-clearfix" id="comment-1518">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://1.gravatar.com/avatar/11cf130976fa9b85904025ec872432d8?s=40&#038;d=mm&#038;r=g' srcset='http://1.gravatar.com/avatar/11cf130976fa9b85904025ec872432d8?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">paulosman</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-1518" class="social-posted-when" target="_blank">April 26, 2009</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>&lt;p&gt;To free the memory allocated for the C++ Car instance, you could add &quot;delete obj-&gt;car;&quot; to the car_free_storage() function anywhere before the &quot;efree(obj);&quot; line. I&#8217;ll edit the article and include that in the example, thanks! &lt;/p&gt;</p>
<p>&lt;p&gt;As for compiling the example code, sorry to hear you are having trouble. Can you download &lt;a href=&quot;<a href="http://www.eval.ca/files/vehicles.tgz&quot;&gt;this" rel="nofollow">http://www.eval.ca/files/vehicles.tgz&quot;&gt;this</a> version&lt;/a&gt; and compile it? If so, you can use that to compare against your own copy. If you have trouble with that, post back here and I&#8217;ll do more troubleshooting. &lt;/p&gt;</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-1518 -->
</li><!-- #comment-## -->
<li class="wordpress odd alt thread-odd thread-alt depth-1 social-comment social-clearfix social-wordpress" id="li-comment-1520">
<div class="social-comment-inner social-clearfix" id="comment-1520">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/cc6f52842142cd96a5ab84779e502ee5?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/cc6f52842142cd96a5ab84779e502ee5?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">sherman81</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-1520" class="social-posted-when" target="_blank">April 24, 2009</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>I built ext. and installed it, but when i try to load and use it from userspace i have following error:</p>
<p>Warning: dl(): Invalid library (maybe not a PHP library) </p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-1520 -->
</li><!-- #comment-## -->
<li class="wordpress even thread-even depth-1 social-comment social-clearfix social-wordpress" id="li-comment-1521">
<div class="social-comment-inner social-clearfix" id="comment-1521">
	<div class="social-comment-header">
		<div class="social-comment-author vcard">
			<img alt='' src='http://0.gravatar.com/avatar/cc6f52842142cd96a5ab84779e502ee5?s=40&#038;d=mm&#038;r=g' srcset='http://0.gravatar.com/avatar/cc6f52842142cd96a5ab84779e502ee5?s=80&amp;d=mm&amp;r=g 2x' class='avatar avatar-40 photo' height='40' width='40' /><cite class="social-fn fn">sherman81</cite>		</div>
		<!-- .comment-author .vcard -->
		<div class="social-comment-meta social-comment-meta-wordpress">
			<span class="social-posted-from">
								<span>View</span>
							</span>
			<a href="http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/#comment-1521" class="social-posted-when" target="_blank">April 24, 2009</a>
		</div>
	</div>
	<div class="social-comment-body">
				<p>And what about dynamic memory alloc/dealloc in c++ classes?</p>
	</div>
			<div class="social-actions entry-meta">
			</div>
		<!-- .reply -->
</div><!-- #comment-1521 -->
</li><!-- #comment-## -->
				</ol>
							</div>
		</div>
			</div>
	<!-- #Comments Tabs -->
	</div>

			
		</div><!-- #content -->
	</div><!-- #primary -->


			<div id="secondary" class="widget-area" role="complementary">
			<aside id="search-3" class="widget widget_search">	<div class="wrapper-search-form">
		<form method="get" id="searchform" action="http://devzone.zend.com/">
			<label for="s" class="assistive-text">Search</label>
			<input type="text" class="txt-search-n" name="s" id="s" />
			<input type="submit" name="submit" id="btn-search-n" value="Search" />
		</form>
    </div></aside><aside id="adrotate_widgets-2" class="widget widget_adrotate_widgets"><div class="g g-2"><div class="g-single a-11"><a class="gofollow" data-track="MTEsMiwxLDYw" href="http://www.zendcon.com"><img src="http://devzone.zend.com/wp-content/uploads/2015/07/Zend_Con_Banner_DevZone_250x250px_01.jpg" /></a></div></div></aside><aside id="nav_menu-4" class="widget widget_nav_menu"><div class="menu-devzone-container"><ul id="menu-devzone" class="menu"><li id="menu-item-6114" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-6114"><a href="http://zend.com">Zend</a>
<ul class="sub-menu">
	<li id="menu-item-6641" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-6641"><a href="http://www.zend.com/en/products/server/z-ray">Z-Ray</a></li>
	<li id="menu-item-6100" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-6100"><a href="http://www.zend.com/en/products/server">Zend Server</a></li>
	<li id="menu-item-6101" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-6101"><a href="http://www.zend.com/en/products/studio">Zend Studio</a></li>
	<li id="menu-item-6102" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-6102"><a href="http://www.zend.com/en/services/training">Zend Training</a></li>
	<li id="menu-item-6103" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-6103"><a href="http://zendcon.com">ZendCon</a></li>
	<li id="menu-item-6115" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-6115"><a href="http://framework.zend.com">Zend Framework</a></li>
	<li id="menu-item-6116" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-6116"><a href="https://apigility.org/">Apigility</a></li>
</ul>
</li>
<li id="menu-item-6117" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-6117"><a href="http://php.net">PHP</a>
<ul class="sub-menu">
	<li id="menu-item-6118" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-6118"><a href="http://planet-php.org">Planet PHP</a></li>
	<li id="menu-item-6119" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-6119"><a href="http://phppodcasts.com">PHP Podcasts</a></li>
</ul>
</li>
</ul></div></aside><aside id="categories-4" class="widget widget_categories"><h3 class="widget-title"><span class="prefix-widget-title"><i class="fa fa-th-large"></i></span> Categories</h3>		<ul>
	<li class="cat-item cat-item-1"><a href="http://devzone.zend.com/category/articles/" >Articles</a>
</li>
	<li class="cat-item cat-item-543"><a href="http://devzone.zend.com/category/cloud/" >Cloud</a>
</li>
	<li class="cat-item cat-item-63"><a href="http://devzone.zend.com/category/events/" >Events</a>
</li>
	<li class="cat-item cat-item-3"><a href="http://devzone.zend.com/category/news/" >News</a>
</li>
	<li class="cat-item cat-item-478"><a href="http://devzone.zend.com/category/php/" >PHP</a>
</li>
	<li class="cat-item cat-item-518"><a href="http://devzone.zend.com/category/review/" >Review</a>
</li>
	<li class="cat-item cat-item-8"><a href="http://devzone.zend.com/category/tutorials/" >Tutorials</a>
</li>
	<li class="cat-item cat-item-474"><a href="http://devzone.zend.com/category/videos/" >Videos</a>
</li>
	<li class="cat-item cat-item-483"><a href="http://devzone.zend.com/category/z-ray/" >Z-Ray</a>
</li>
	<li class="cat-item cat-item-60"><a href="http://devzone.zend.com/category/zend-framework/" >Zend Framework</a>
</li>
	<li class="cat-item cat-item-300"><a href="http://devzone.zend.com/category/zend-server/" >Zend Server</a>
</li>
	<li class="cat-item cat-item-213"><a href="http://devzone.zend.com/category/zend-studio/" >Zend Studio</a>
</li>
		</ul>
</aside><aside id="rss-3" class="widget widget_rss"><h3 class="widget-title"><span class="prefix-widget-title"><i class="fa fa-th-large"></i></span> <a class='rsswidget' href='http://phpdeveloper.org/feed'><img style='border:0' width='14' height='14' src='http://devzone.zend.com/wp-includes/images/rss.png' alt='RSS' /></a> <a class='rsswidget' href='http://www.phpdeveloper.org/'>phpdeveloper.org</a></h3><ul><li><a class='rsswidget' href='http://www.phpdeveloper.org/news/23126'>PHP.net: PHP 5.6.13 &amp; 5.5.29 Released</a></li><li><a class='rsswidget' href='http://www.phpdeveloper.org/news/23125'>Site News: Popular Posts for This Week (09.04.2015)</a></li><li><a class='rsswidget' href='http://www.phpdeveloper.org/news/23124'>Ignace Nyamagana Butera: Q&amp;A: Enforcing enclosure with League\Csv</a></li><li><a class='rsswidget' href='http://www.phpdeveloper.org/news/23123'>SitePoint PHP Blog: PHP Summer Camp 2015 Review</a></li><li><a class='rsswidget' href='http://www.phpdeveloper.org/news/23122'>Run Geek Radio: Episode 008 – Escaping PHP Variables Forgotten</a></li></ul></aside><aside id="rss-4" class="widget widget_rss"><h3 class="widget-title"><span class="prefix-widget-title"><i class="fa fa-th-large"></i></span> <a class='rsswidget' href='http://feeds.feedburner.com/PhpPodcasts'><img style='border:0' width='14' height='14' src='http://devzone.zend.com/wp-includes/images/rss.png' alt='RSS' /></a> <a class='rsswidget' href='http://www.phppodcasts.com/'>PHP Podcasts</a></h3><ul><li><a class='rsswidget' href='http://www.phppodcasts.com/2015/09/03/episode-008-escaping-php-variables-forgotten/'>Episode 008 – Escaping PHP Variables Forgotten</a></li><li><a class='rsswidget' href='http://www.phppodcasts.com/2015/09/01/030-soa-and-microservices/'>030: SOA and Microservices</a></li><li><a class='rsswidget' href='http://www.phppodcasts.com/2015/09/01/24-wes-bos-what-the-flexbox/'>24: Wes Bos – What the Flexbox?!</a></li><li><a class='rsswidget' href='http://www.phppodcasts.com/2015/09/01/interview-with-anthony-ferrara-2/'>Interview with Anthony Ferrara</a></li><li><a class='rsswidget' href='http://www.phppodcasts.com/2015/08/28/magetalk-episode-63-thats-not-possible-feat-ben-staveley/'>MageTalk Episode 63 – “That’s Not Possible” [feat Ben Staveley]</a></li><li><a class='rsswidget' href='http://www.phppodcasts.com/2015/08/27/php-and-javascript-innovation-award-report-august-2015-edition-may-2015-nominees/'>PHP and JavaScript Innovation Award Report August 2015 Edition – May 2015 nominees</a></li><li><a class='rsswidget' href='http://www.phppodcasts.com/2015/08/25/029-the-only-girl-in-the-room/'>029: The Only Girl In The Room</a></li><li><a class='rsswidget' href='http://www.phppodcasts.com/2015/08/25/interview-with-josh-butts-2/'>Interview with Josh Butts</a></li><li><a class='rsswidget' href='http://www.phppodcasts.com/2015/08/24/magetalk-episode-62-i-like-git-butts-and-i-cannot-lie/'>MageTalk Episode 62 – “I Like Git Butts and I Cannot Lie”</a></li><li><a class='rsswidget' href='http://www.phppodcasts.com/2015/08/23/magetalk-episode-61-bad-case-of-brontitis/'>MageTalk Episode 61 – Bad Case of “Brontitis”</a></li></ul></aside>		</div><!-- #secondary -->
		</div><!-- #main .wrapper -->
	<footer id="colophon" role="contentinfo">
		<div class="site-info">
			<div class="credits credits-left">Copyright 2015</div>
			<div class="credits credits-center"><a href="http://zend.com">Zend</a></div>
			<div class="credits credits-right">
			<a href="/wordpress-themes/zerogravity">ZeroGravity</a> by GalussoThemes.com<br />
			Powered by<a href="http://wordpress.org/" title="Semantic Personal Publishing Platform"> WordPress</a>
			</div>
		</div><!-- .site-info -->
	</footer><!-- #colophon -->
</div><!-- #page -->

		<a href='#inicio_pagina' title='Back to top'><div class="ir-arriba"><i class="fa fa-chevron-up"></i></div></a>
	<script type='text/javascript'>
/* <![CDATA[ */
var click_object = {"ajax_url":"http:\/\/devzone.zend.com\/wp-admin\/admin-ajax.php"};
/* ]]> */
</script>
<script type='text/javascript' src='http://devzone.zend.com/wp-content/plugins/adrotate-pro/library/jquery.adrotate.clicktracker.js'></script>
<script type='text/javascript'>
/* <![CDATA[ */
var Sociali18n = {"commentReplyTitle":"Post a Reply"};
/* ]]> */
</script>
<script type='text/javascript' src='http://devzone.zend.com/wp-content/plugins/social/assets/social.js'></script>
<script type='text/javascript' src='http://devzone.zend.com/wp-content/themes/zerogravity/js/navigation.js'></script>
<script type='text/javascript' src='http://devzone.zend.com/wp-content/themes/zerogravity/js/zg-toggle-search.js'></script>
<!-- AdRotate JS -->
<script type="text/javascript">
</script>
<!-- /AdRotate JS -->


</body>
</html>